Net.Mobile to implement barcode scanning into an app.
I currently have a little demo app that has implemented a scanning page, I can read barcodes and do something. I'm using Xamarin Forms to implement the barcode scanning. I looked at the sample app provided by ZXing and copied the code for one of their scanners to use in my demo. Now i have tested this app in android, I'm using an API 21 phone and it lags like hell but all in all it works. I can scan a barcode and navigate to a new screen.
When testing on iOS (using an iphone 6 on the latest version - 11.2.5) I noticed that the iphone never stops reading barcodes. Here is the code that get called when the phone recognises a barcode:
zxing.OnScanResult += (result) =>
Device.BeginInvokeOnMainThread(async () => {
// Stop analysis until we navigate away so we don't keep reading barcodes
zxing.IsAnalyzing = false;
// Show an alert
await DisplayAlert("Scanned Barcode", result.Text, "OK");
// Navigate away
await Navigation.PushAsync(new ScanResultsPage());
});
So as you can see the first thing that gets called when a barcode is recognised is zxing.IsAnalyzing = false;
, this works on android. However on iOS it continues scanning and if I point the phone at the barcode, more and more alerts get added to the screen. I am new to Xamarin Forms and have never encountered any issues when adding barcodes to iOS natively.
I don't really know where to begin debugging this, I put a breakpoint on this line of code zxing.IsAnalyzing = false;
, it executes and I can see the value is set to false.
Could this be an issue with the ZXing framework itself?
Thanks
(I have called init in the app delegate)