Phonegap Build How Do You Add Plugins To App
The document says: 'There are two steps to including a plugin in your project: Importing the native code using the config.xml Referencing the JavaScript code for the plugin' http:/
Solution 1:
if you want to include the bar code scanner with phonegap build you coulde do the following,
<?xml version="1.0" encoding="UTF-8" ?><widgetxmlns = "http://www.w3.org/ns/widgets"xmlns:gap = "http://phonegap.com/ns/1.0"id = "com.phonegap.example"versionCode = "10"version = "1.0.0" ><!-- versionCode is optional and Android only --><name>PhoneGap Example</name><description>
An example for phonegap build docs.
</description><authorhref="https://build.phonegap.com"email="support@phonegap.com">
Hardeep Shoker
</author><!-- We'll include the Barcode plugin as an example --><gap:pluginname="com.phonegap.plugins.barcodescanner" /><gap:pluginname="org.apache.cordova.camera"/><gap:pluginname="org.apache.cordova.device-motion"/><gap:pluginname="org.apache.cordova.device-orientation"/><gap:pluginname="org.apache.cordova.file-transfer"/><gap:pluginname="org.apache.cordova.geolocation"/><gap:pluginname="org.apache.cordova.dialogs"/><gap:pluginname="org.apache.cordova.vibration"/></widget>
This is an example config.xml file to include in the same directory as your homepage. In the javascript file you don't include any scripts for plugins(make sure
<scriptsrc="cordova.js"></script>
is included). Just call the plugin methods and build will handle the rest for you.For example I have included the vibration plugin above. If I wanted my phone to vibrate I would simply call a function like this,
function test(){
navigator.notification.vibrate(1000);
}
There is no need for anything like,
<scriptsrc="barcodescanner.js"></script>
Just make sure the plugin is referenced in the config.xml file and everything should be ok
Post a Comment for "Phonegap Build How Do You Add Plugins To App"