I am relatively new to phonegap/cordova. I am integrating the barcode scanner plugin into my app but can not get it to work on iOS or Android app.
These are the steps for my Android implementation:
I am successfully installing the plugin into my project directory from the CLI using:
cordova plugin add com.phonegap.plugins.barcodescanner
I can see that the plugin is in my project plugins folder. Strange thing is my config.xml does not get
as I read it should so I have done it myself. This is another point of confusion as I am not exactly sure
which of the 3 different ways I have seen that I Should actually use.
1.
<plugins>
<plugin name="BarcodeScanner" value="com.phonegap.plugins.barcodescanner"/>
</plugins>
2.
<feature name="BarcodeScanner">
<param name="android-package" value="com.phonegap.plugins.barcodescanner" />
</feature>
3.
<gap:plugin name="com.phonegap.plugins.barcodescanner" />
So the example usage for the scanner is given as this:
cordova.plugins.barcodescanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);
In my app I have a button in one of my html files:
<div data-role="button" onClick="scan()" style="border:3px solid #000000; color:white; background:#009000;">
Scan
</div>
which calls the function scan() which contains the usage example above, but when I run on my device i get this error:
01-27 15:17:43.361: E/Web Console(30120): Uncaught TypeError: Cannot read property 'barcodescanner' of undefined:356
I have googled this error and tried out many of the solutions offered but I can not get this plugin to work in my app. Can someone please help?
0 comments:
Post a Comment