I am fairly new to Ionic development and thus far has not run into too many problems. However, I am stuck on trying to get PDF417 type bar-codes to scan (using phonegap-plugin-barcodescanner), despite the documentation suggesting that they are supported via pass the "PDF_417" parameter in the "formats" option. Note: the scanning works on other codes such as QR_CODE, EAN_13 - So the code is mostly right. I don't think that the options list after the error function is being processed.
$cordovaBarcodeScanner.scan().then(function(imageData) {
$scope.si_data_display = imageData.text;
console.log("app.js :: .controller - MainCtrl :: scan_barcode :: text : " + imageData.text);
console.log("app.js :: .controller - MainCtrl :: scan_barcode :: format : " + imageData.format);
console.log("app.js :: .controller - MainCtrl :: scan_barcode :: cancelled : " + imageData.cancelled);
}, function(error) {
//TODO: better error handling...
alert("Error with BarcodeScanner" + error);
},
{ //I DONT THINK THIS IS WORKING!
"preferFrontCamera" : true, // iOS and Android
"showFlipCameraButton" : true, // iOS and Android
"prompt" : "zzzzzzzzzzzz", // supported on Android only
"formats" : "PDF_417", // default: all but PDF_417 and RSS_EXPANDED
});
Any help, suggestion and or pointers will be gratefully received.
Thank you in advance, Harold Clements
Yes, you have badly written the code, you have an error in the $cordovaBarcodeScanner.scan() funtion, because it is a promise, therefore it returns two callbackFuntion from .them method
q.resolve(result);
q.reject(err);
$CordovaBarcodeScanner ia a factory that returns two functiosns
A function with an input argument
scan: function (config) {
and the secondone with two input arguments
encode: function (type, data) {}
bouth are promise functios
so the correct way to make the request is:
in your html
Reviewing the ios library, it only contains the following types of formats, so it does not work for iOS. If you find some method to scan PDF417 in ios using IONIC, you can share it!
I hope it will be useful for everyone