0
votes

I am using phonegap build version cli-5.2.0 and the barcodescanner plugin.

I've added the plugin to the config.xml:

And then in my index.html page I've added:

<script>
function clickScan() {

alert('tester');

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);
      }
   );


};
</script>

THen a button:

<button onclick="clickScan();">Scan</button>

The alert is coming out but the scanner is not opening.

What I'm I doing wrong here?

1

1 Answers

0
votes

I got it working.

I had to add:

<script src="phonegap.js"></script>
<script src="barcodescanner.js"></script>

to the index.html page. That solved it in my case.