[BarcodeScanner Plugin] Upgrading scanner JavaScript API, code changes required

  • 1
  • Announcement
  • Updated 6 years ago
The BarcodeScanner Plugin on PhoneGap Build will be getting an update today, and apps using it will need to change their code to use cordova.require:

Old:
window.plugins.barcodeScanner.scan(function(){ ... }, function(){ ... }, optionsObj)

New:
var scanner = cordova.require("cordova/plugin/BarcodeScanner");

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


More info:
https://github.com/phonegap/phonegap-...
http://simonmacdonald.blogspot.ca/201...

Will update this thread once the the new version is deployed.
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes

Posted 7 years ago

  • 1
Photo of Darnell Ford

Darnell Ford

  • 0 Posts
  • 0 Reply Likes
Redownloading and reinstalling fixed my problem.
Photo of R3dRuM

R3dRuM

  • 15 Posts
  • 0 Reply Likes
Thanks Darnell! That solved my problem... Had to uninstall the app and reinstall it with the same sources. Working now.
problem solved
Photo of ColinBau

ColinBau

  • 730 Posts
  • 18 Reply Likes
I have new problem right here
https://github.com/wildabeast/Barcode...
someone can help me?
Photo of hongdida

hongdida

  • 1 Post
  • 0 Reply Likes
I have new problem right here
https://github.com/wildabeast/BarcodeScanner
someone can help me?


try reinstalling.