Is there any way to cancel a barcode scan after timeout? I found that sometimes some phones would not pick up the qr code for some reason (e.g. lens dirty, bad focus…) and I have the users trying and trying to scan without success and getting frustrated through the process.
So I am looking for an option to start the scan() function, then after, say 15 seconds pop up a message saying something like “having trouble?” and then provide some other option, for instance to enter a code manually or contact an operator or something.
Is there anything like that built in? Couldn’t find it in the docs.
Thanks! But no, I manage to scan successfully and everything works… as long as the phone can detect the code.
If the phone does not detect the code for a long time, it stays in the scan page forever. I was looking for a way to get out of scan mode after a while if no code was detected.
I am not sure where to provide the $timeout you mention in the scan call. This is what I do:
this.barcodeScanner
.scan({
preferFrontCamera: false, // iOS and Android
showFlipCameraButton: false, // iOS and Android
showTorchButton: true, // iOS and Android
torchOn: false, // Android, launch with the torch switched on (if available)
resultDisplayDuration: 500,
formats: 'QR_CODE,PDF_417'
})
.then((data) => {
// This happens when the QR was captured
this.check(data.text);
})
.catch((err) => {
// This seems to happen only when the "back" button is pressed
this.showCancelledAlert();
});
}
So it is only cancelled when “back” is pressed. Is there any BarcodeScannerOptions to provide such $timeout that takes me to the “catch” after some time?