ZXing Scanner not scanning on iOS in Xamarin Forms app - ios

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

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.

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

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 |......

Related

Google Map don't load in iOS

I’m using GoogleMaps pod in my iOS application and it was working fine, but in my last build, apple reject my application. And the reason behind that is, the map was unable to load at the time of review on iPad running iOS 12.2 on Wi-Fi.
I did try to reproduce that bug on my device but I couldn’t.
Application do ask for location permission
Google Place API key also seems ok.
Is there any way to identify what the actual issue is and how I am supposed to solve this one?
Finally, I've solved that issue and for that, I've done some of the changes in my project.
1 - I've patched the latest Google Plist file in the project (I wasn't sure whether the old one was latest or not)
2 - I was using multi language in my project so before setting the delegate of google map, I've set the language for my project.
3 - instead of set the google map from Storyboard, I've set the google map programmatically in my view controller after setting language.
After surfing for so long to solve this issue, I came to know that this issue occurs when your App supports multi language. These some steps did work for me.

Ionic 2 Storage does not work on iOS

I am using #ionic/storage as it looked quite promising after reading about it in the V2 Docs.
I use Chrome on my Windows 10 laptop so things appeared to be working perfectly fine at first. However, when I tested it on iPad, or even Firefox on my laptop, I was surprised to find out it did not work.
I was able to resolve the issue on Firefox by removing the sqlite plugin (I thought I will add it when I am ready for native testing):
cordova plugin remove cordova-sqlite-storage --save
Sadly, storage still doesn't work on the iPad. I tested it on Safari and Chrome. I am unable to debug this given the lack of developer tools or console.
I am quite frustrated how Apple makes you dependent on using a Mac to develop on their devices.
How do I go about fixing and debugging this?
I first import storage in Ionic 2:
import { Storage } from '#ionic/storage';
Then to save the data, I do this:
this.storage.set(pk, JSON.stringify(reportObj));
Where pk is just a unique key, and reportObj is an object that I stringify before storing. Again, keep in mind this just doesn't work in iOS.
Thanks.
Update:
So I managed to run the app in Safari and found out that .set actually works and the data gets stored in WebSQL. However, the get does not seem to work and I wasn't able to get any useful errors in the console.
OK, so after a lot of trial and error, I found out that the problem is not really with Storage. There appears to be some other issue with my UI, where it doesn't seem to work on iOS.
I decided to answer the part about testing the app on iOS while in development if you are not a Mac user. The best way for this appears to be to use Ionic View. You can use this simply by typing:
ionic upload
Make sure you create your account. In your iPad or iPhone, you can then download Ionic View app from iTune, sign in, and the app will appear there.
As you upload your code, simply upload again and almost instantly the app would upload on the device as you click Sync.
Hope other Windows users benefit from this.

phonegap iOS app working on simulator but not in device. How to debug

I just finished developing a Cordova / Phonegapp app. When I test it on iOS simulator it all works fine and quick, but, when testing on device it works only part of it.
My app is a game with the kingdom background and has 8 buttons (8 buildings).
When I click on each building it leads me to a screen representing what it's inside the building, but one of them doesn't work and gets my app frozen.
How can I see fail or crash reports that helps me debug my app on device?
If you provide full path to your file i.e. "file:///Users/.../someDir/some.html" it will work only on simulator running on the same machine where your project is.
I suggest just adding the additional path to the file you want to access i.e. if you are in "/someDir" you will need to provide only "some.html" or if you want to access parent directory just use "../".
As far as debugging Cordova app, I suggest downloading this plugin and using console.log instead of alert.
Hope this helped.
Ok, I found a "spartan" way to debug my app via alert and found that an url wasn't set properly (still don't know why it worked on simulator)

Is there a way to get programmatically UI hierarchy for 3rd party application on iOS?

I am looking for a way to get programmatically UI hierarchy of 3rd party application.
Couple of constrains:
I am looking for a way to get UI of 3rd party app (so I can't include any library in it or change a code)
It should work on a real iOS device (not on Simulator)
It should work with non jailbroken device.
It should work with native app
I am fine with either:
A desktop tool which can access iOS and get info about an app hierarchy
An iOS app which can get UI hierarchy for 3rd party app while being in the background
I am fine with usage of private API (it won't be submitted to AppStore)
Any ideas (even if they aren't complete solution) are welcome.
SparkInspector http://www.sparkinspector.com is similar to Reveal, but I'm not sure is it able to work with real device.
I recommend DCIntrospect: https://github.com/domesticcatsoftware/DCIntrospect
Also there is Reveal: http://revealapp.com
You can inject the Reveal dynamic library into a third-party application using MobileSubstrate. This can only be performed though via a jailbroken device. Blog post describing the process:
http://www.zdziarski.com/blog/?p=2361

IBM Worklight 5 - iOS app shows white screen on second launch

I'm having a problem with a hybrid app for iOS which I have written using Worklight 5. The problem is that the application only runs properly the first time it is launched, and after being closed in multi-tasking and relaunched, the app will not open properly and instead displays a white screen. The only way to get the application to run again is to delete it from the device completely and then re-install it.
This behaviour is the same in the iPad simulator and on a physical iPad.
I don't have any code to provide as all of the Objective-C is generated by Worklight and all I have written is the HTML5, CSS3 and Javascript and I think that's unlikely to be affecting it. Has anybody else experienced this issue and if so is there a way to resolve this problem? Thanks.
Actually the behavior sounds to me much more inline with changing the name of the HTML file itself and in application-descriptor.xml's mainFile element. Have you touched these? If yes, then you also need to change the name of the application's folder.
Here's something to try:
Open cordova.js inside the Xcode project.
Replace: execXhr.open('HEAD', "/!gap_exec", true);
With execXhr.open('HEAD', "/!gap_exec?" + +new Date, true);.
It's from a fix that was applied to Cordova 2.4. It adds a timestamp to the query param to prevent caching.
No idea if that will help, it sounds vaguely familiar to an issue I ran into.

Resources