Created
February 2, 2011 23:25
-
-
Save mwbrooks/808682 to your computer and use it in GitHub Desktop.
Plugin example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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