74

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

laalto
  • 150,114
  • 66
  • 286
  • 303
Newbee
  • 1,320
  • 4
  • 16
  • 21

5 Answers5

47

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"}
    );
 }      
RobLabs
  • 2,257
  • 2
  • 18
  • 20
  • does anybody know the password for the zip? I cant unzip the package, it requires a password. – 最白目 Nov 03 '11 at 09:46
  • Dear Rob, I have some confused. In my opinion, In Barcode Reader, we don't use PhoneGAP. We connect directly with Camera ANdroid or Iphone PhongeGap use Browse (HTML or Javascript) to call Apps. But no where to use Browse. Thanks you – LTEHUB Jan 16 '12 at 09:09
  • Hello @maydenec, I don't think I understand the comment/question. Sounds like you are not using PhoneGap. Is that true? Can you edit? – RobLabs Jan 31 '12 at 18:39
  • In case you want to go straight to the plugin: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner – Daniel Bang May 14 '12 at 03:16
10

This link leads you to a page where you can learn how to implement the PhoneGap Barcode Scanner plugin in your application

OrangeTux
  • 11,142
  • 7
  • 48
  • 73
  • 8
    Whilst this may theoretically answer the question, we would like you to include the essential parts of the linked article in your answer, and provide the [link for reference](http://meta.stackexchange.com/q/8259). Failing to do that leaves the answer at risk from link rot. – Kev Sep 26 '12 at 00:45
  • 1
    It looks to be specifically for Android though. Is there an equivalent for Windows Phone? – Ciaran Gallagher Nov 07 '12 at 23:26
10

Your going to have a build a Phonegap plug-in, but the hard work has already be done for you by zxing.

Kris Erickson
  • 33,454
  • 26
  • 120
  • 175
  • 1
    Hi Can you please give pointers as to how to use ZXing implementation in application. I am unable to make the use the same in my application. – Newbee Oct 14 '10 at 08:57
1

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.

KaySubb
  • 71
  • 2
0

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

Prabhunath Yadav
  • 185
  • 1
  • 14