Reputation: 30344
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
Upvotes: 1
Views: 2407
Reputation: 21
I had the same issue.
The only thing I did was that I've changed the Xamarin.IOS to the latest version (16.0.0.75).
By using Visual Studio => go to Help/Check for Updates
It solved the problem.
Upvotes: 2
Reputation: 179
i had similar issue, it was working for more than a year then all of sudden all my users complaint its not working anymore, after ios update. the apps just crash whenever it tried to call the barcode scanning camera using zxing.
the solution was easy in my case, just recompile it using latest xamarin.ios version. just need to make sure the version is up to date
Upvotes: 1
Reputation: 1
I also faced this issue and found the solution.
Instead of using metadataoutput.AvailableMetadataObjectTypes
, you need to set all code types in an array of AVMetadataObjectType
, for ex:
AVMetadataObjectType.EAN8Code | AVMetadataObjectType.EAN13Code |
AVMetadataObjectType.Code39Code | AVMetadataObjectType.Code128Code |......
Upvotes: 0