简体   繁体   中英

Barcode Scanner phonegap/cordova plugin on Windows Phone 7

I'm trying to implement the barcode scanner plugin on windows phone 7. I carried out the following steps according to the plugin's readme :
1. Added both the dll's to my project.
2. Added barcodescanner.js to the 'www' folder and included the js file in my 'index.html'.
3. Added BarcodeScanner.cs to my project.

I didn't find any guide to implement this on the windows phone platform, so i tried using this guide which was for Android to write the html/js for using the plugin. I have inlcuded a button whose onclick calls the 'Scan()' function :

function Scan() {
window.plugins.barcodeScanner.scan(
    function(result) {
    alert("Scanned Code: " + result.text 
            + ". Format: " + result.format
            + ". Cancelled: " + result.cancelled);
}, function(error) {
    alert("Scan failed: " + error);
});
}

On running the app and clicking the button, I'm getting the following error in the console window :

Error:"Unable to get value of the property 'barcodeScanner': object is null or undefined file:x-wmapp1:/app/www/index.html Line:45"

How do i get this to work?

This was an issue related to Phonegap 2.7. It worked, somehow, when i tried it on 2.9.0.

您是否在config.xml中添加了<plugin name="org.apache.cordova.barcodeScanner">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM