Cordova/Phonegap QRcode Scanner


#1

Hi, anyone have experience with this Cordova/Phonegap plugin?

I install the plugin with the following command: meteor add cordova:phonegap-plugin-barcodescanner@6.0.8

Then meteor run android-device

I see from shell the plugin is download and installed. But when I click on button that trigger the following example code:

cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      },
      function (error) {
          alert("Scanning failed: " + error);
      },
      {
          preferFrontCamera : true, // iOS and Android
          showFlipCameraButton : true, // iOS and Android
          showTorchButton : true, // iOS and Android
          torchOn: true, // Android, launch with the torch switched on (if available)
          saveHistory: true, // Android, save scan history (default false)
          prompt : "Place a barcode inside the scan area", // Android
          resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
          formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
          orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
          disableAnimations : true, // iOS
          disableSuccessBeep: false // iOS and Android
      }
   );

I get error from shell stating:

"Uncaught TypeError: Cannot read property 'barcodeScanner' of undefined"

Please help give some hints or guidance on how to successfully use the plugin? Please help, thanks.


#2

I think this could very well be a version mismatch between the barcode scanner plugin and the cordova-andoid version. I would make sure you’ve updated to the latest Meteor release and use the latest version of the plugin as well.


#3

@copleykj

Meteor are updated. The plugin I take the latest version. What else could be wrong? Please advice, thanks.


#4

In your original post you stated you were using cordova:phonegap-plugin-barcodescanner@6.0.8. It appears the latest version is 7.1.2. If you have updated to this version and still not had success, then I’m not sure what the issue could be. Best I can tell you is to see about providing a reproduction and maybe someone will take the time to build it and see if they can figure it out.


#5

I’m very sorry I check the Changelog and that show 6.0.8. I will try 7.1.2 and will post my update here. Thanks.


#6

No need to be sorry. I volunteered my time to help :slight_smile:


#7

It’s working! Thank you so much for pointing me to the right direction. Appreciate very much. Now I need to solve the external REST API call to solve all my current project problem. Thanks again.


#8

Any time my friend :blush: