how to scan barcode using phonegap

后端 未结 5 1691
走了就别回头了
走了就别回头了 2020-12-07 07:54

I need to scan a barcode using phonegap in Android and iPhone. Is there a way to do this?

5条回答
  •  天命终不由人
    2020-12-07 08:29

    Kris Erickson is correct, the Zxing & Phonegap projects has already taken care of the heavy lifting for you. (My current SO reputation disallows me from commenting, but I would have.)

    I've just made an Phonegap/Android app that scans a QR barcode using the plugin here. Follow the instructions and you should be successful. It's possible that the plugin has been written since Kris's answer.

    The Javascript is simple, taken straight from https://github.com/phonegap/phonegap-plugins/

        var scanBarcode = function() {
        window.plugins.barcodeScanner.scan( BarcodeScanner.Type.QR_CODE,function(result) {
            alert("We got a barcode: " + result);
        }, function(error) {
            alert("Scanning failed: " + error);
        }, {yesString: "Install"}
        );
     }      
    

提交回复
热议问题