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" ?>
<widget xmlns = "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>
<author href="https://build.phonegap.com" email="support@phonegap.com">
Hardeep Shoker
</author>
<!-- We'll include the Barcode plugin as an example -->
<gap:plugin name="com.phonegap.plugins.barcodescanner" />
<gap:plugin name="org.apache.cordova.camera"/>
<gap:plugin name="org.apache.cordova.device-motion"/>
<gap:plugin name="org.apache.cordova.device-orientation"/>
<gap:plugin name="org.apache.cordova.file-transfer"/>
<gap:plugin name="org.apache.cordova.geolocation"/>
<gap:plugin name="org.apache.cordova.dialogs"/>
<gap:plugin name="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
<script src="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,
<script src="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"