I'm new to Ionic and Cordova. I need to create a plugin for ionic using Cordova and integrate it in sample ionic app.
Steps I Followed are:
Created a simple ionic plugin using plugman
plugman create --name SayHello --plugin_id cordova-plugin-sayhello -plugin_version 0.0.1
Added android platform to above plugin.
cd SayHello/ && plugman platform add --platform_name android
Now I want to integrate this plugin into my ionic app.
ionic cordova plugin add ../SayHello
In my ionic app inside Home.ts, I wrote this piece of code.
declare var cordova: any;
var success = function(result) {
console.log(result);
}
var failure = function(err) {
console.log(err);
}
cordova.plugins.HelloWorld.coolMethod("SayHelloTest", success, failure);
The problem is I cannot call any function from success or failure in the ionic app.
like if I call function doSomething from success:
var success = function(result) {
doSomething(result);
}
It Shows Error doSomething function not found. It can only print in console.
To install plugman, you must have node installed on your machine. Then you can run the following command from anywhere in your environment to install plugman globally, so that it is available from any directory:
Once you have installed Plugman and have created a Cordova project, you can start adding plugins to the platform with: