Phonegap plugins allow you to use functionalities on native platform through
successFun (Function): if your
execcall completes successfully, this function is invoked (optionally with any parameters you pass back to it).
failFun (Function): if the operation does not complete successfully, this function is invoked (optionally with an error parameter).
service (String): the service name to call into on the native side.
action (String): the action name to call into.
args (Array): arguments to pass into.
On the native platform, you needs to implement the
service (as class name), which
CordovaPlugin and overides
Your plugin must be added to the
config.xml file in your Cordova-Android application’s
This is a plugin template:
args: the arguments passed in.
You can access your cordova activity and context using
You can pass data back using
For example, you can refer to the source code
Notification API provided by phonegap.
It is better to wrap your plugin calls, instead of calling
directly every time. There are two ways doing it:
The Common Way
This is the common way found in phonegap-plugins repos:
The Require Way
This is what I found in
cordova.js’s source code:
require is not compatible with old Phonegap (1.x).