3 Replies Latest reply on Oct 2, 2016 1:08 PM by andersborglund

    Create Phonegap app with barcode scanner


      Hello all,


      I am in need of a lot of help with creating an app with barcode/qr code scanner plugins.


      I have searched everywhere and found a few examples or plugins and tried getting them to work with no luck. I cannot seem to get the plugin installed correctly as it says it cannot be found or 'barcodeScanner' is undefined. Does not work on phonegap emulator or device it self.


      Please could anyone help me out with an example/tutorial for a barcode scanner? Its driving me insane.


      Thanks so much.

        • 1. Re: Create Phonegap app with barcode scanner

          When you say that you've tried on device, did you use the Phonegap Developer Mobile App? If that's the case, it's normal that the barcode scanner plugin didn't work because most plugins don't work with the Developper App. This app is great to make some testing, but not when plugins are involved.


          You have to connect your phone with an USB cable and build the app into it with the command line "phonegap run android".


          Please note that the developper mode must be enabled on your phone. It's tricky because this setting is hidden. You have to press 7 times the build number section to make it appear:


          How to enable Developer Options on your Android phone or tablet | Greenbot


          You can use the command line "adb devices" to make sure that your phone is detected.

          • 2. Re: Create Phonegap app with barcode scanner
            kerrishotts Adobe Employee



            Please indicate exactly which plugins you tried, the version #s of those plugins, and how they failed. Share the code of how you used those plugins as well, since that might help us narrow down the issue. It might also help to see your config.xml and index.html (minus identifying information).


            Also, what are you using to build the app? PhoneGap Build, PhoneGap CLI, Cordova CLI? Or as @baspey asked, are you using the developer app?


            And finally, what platforms are you targeting/testing on (include version numbers)?

            • 3. Re: Create Phonegap app with barcode scanner
              andersborglund Level 2

              Look no further.


              Add this to config.xml:


                  <plugin name="cordova-plugin-barcodescanner" />


              Add this to your code:



                                  function(result) {

                                      console.log("Success: " + JSON.stringify(result));

                                      if (!result.cancelled) {

                                          // Methodology is in result.format

                                          // Data is in result.text



                                  function(result) {

                                      status("Failure: " + result);




              More info: cordova-plugin-barcodescanner