I'm using the 3.1.0-beta
version of ZXing.Net.Mobile
and ZXing.Net.Mobile.Forms
in my Xamarin Forms 5 app.
Everything is working fine on Android but on iOS, it just doesn't seem to scan at all on an actual device connected to my PC via USB. I also packaged the app and uploaded it for TestFlight testing. When I test it as a fully installed app on my iPhone, it actually crashes the app all together.
My research shows this may happen due to permission issues. I do have the following in Info.plist
:
<key>NSCameraUsageDescription</key>
<string>MyApp would like to access your camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>MyApp would like to access your microphone</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>MyApp would like to access your photo library</string>
Though it's not working on my iPhone Xs, the same setup is working just fine on both Android emulator and a cheap LG phone.
There's not much code to show here but here's what I have in my XAML file:
<zxing:ZXingScannerView
IsScanning="True"
OnScanResult="OnScanCompleted"/>
I also want to mention that my app uses the MVVM
pattern so here's what I've done to wire things: the OnScanCompleted
is in XAML page's code behind that looks like this:
private async void OnScanCompleted(ZXing.Result result)
{
await _vm.On_Code_Scanned(result.Text);
}
So, I call a method in my view model from OnScanCompleted
which is in code behind.
And the method in view model is fairly simple:
public async Task On_Code_Scanned(string code)
{
// Process code
}
Any idea how to fix this issue?
UPDATE:
I started a fresh new Xamarin Forms app. I then added ZXing.NetMobile
and ZXing.Net.Mobile.Forms
and nothing else. When I test scanning a QR code on my iPhone Xs, it still fails. So, it looks like this particular libary just doesn't work on iOS at all