Skip to content

Instantly share code, notes, and snippets.

@mwbrooks
Created February 2, 2011 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwbrooks/808682 to your computer and use it in GitHub Desktop.
Save mwbrooks/808682 to your computer and use it in GitHub Desktop.
Plugin example
(function() {
var Battery = function() {
return {
//
// Get a battery property
//
// @param property to get. Only 'Power' is supported.
// @param successCallback is provided an argument { level: [0, 100] }
// @param errorCallback is called on any native error and provided a message
//
get: function(property, successCallback, errorCallback) {
PhoneGap.exec(successCallback, errorCallback, 'Battery', 'get', [ property ]);
}
}
};
PhoneGap.addConstructor(function() {
// add plugin to window.plugins
PhoneGap.addPlugin('battery', new Battery());
// register plugin on native side
phonegap.PluginManager.addPlugin('Battery', 'com.phonegap.plugins.Battery');
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment