Hi everyone,
I have been using Ionic 4 for my mobile application. I have installed phonegap-plugin-barcodescanner plugin for barcode scanning which is encoded in code128 format. But due to some unknown reason, the plugin is reading barcodes with lengths < 20 with ease but cannot read barcodes with higher lengths. I have read every documentation but have been unable to solve it. Any help will be appreciated.
Code:
// mtype: to check if I am calling it from old meter or new meter
goToBarcodeScan(mtype) {
const options: BarcodeScannerOptions = {
preferFrontCamera: false,
showFlipCameraButton: true,
showTorchButton: true,
torchOn: false,
prompt: 'Place a barcode inside the scan area',
resultDisplayDuration: 500,
orientation: 'landscape',
formats: "CODE_128:32"
};
var observers=this.platform.backButton.observers;
// empty the back buttton observers...
this.platform.backButton.observers=[]; //empty array
this.barcodeCtrl.scan(options).then((barcodeData) => {
console.log('Barcode data', barcodeData.text);
console.log('Barcode data raw', barcodeData);
this.alrt.presentMsg(barcodeData.format+" - "+ barcodeData.text+" - "+barcodeData.text.length);
// this is keep app getting two backs on pressing native back button
setTimeout(()=>{this.platform.backButton.observers=observers},500); // important to provide some time to close barcode
if(mtype){
this.mserialno = barcodeData.text;
}else{
this.oldmserialno = barcodeData.text;
}
}).catch(err => {
this.alrt.presentAlert("Error occured: "+ err);
console.log('Error', err);
});
}
Result:
Plugin just keep scanning the barcode and does not give any error or result.