Reputation: 1310
I need to scan a barcode using phonegap in Android and iPhone. Is there a way to do this?
Upvotes: 73
Views: 55594
Reputation: 185
https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner here is some useful example that help to do your solution https://build.phonegap.com/plugins/13
Upvotes: 0
Reputation: 11451
This link leads you to a page where you can learn how to implement the PhoneGap Barcode Scanner plugin in your application
Upvotes: 10
Reputation: 71
I recently used the ZBar plugin + the PhoneGap plugin to access ZBar. More details here - http://blog.infoentropy.com/Use_ZBar_barcode_reader_with_PhoneGap.
Upvotes: 1
Reputation: 2347
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"}
);
}
Upvotes: 47
Reputation: 33834
Your going to have a build a Phonegap plug-in, but the hard work has already be done for you by zxing.
Upvotes: 10