I just upgrade my phone to iOS 10.2.1.
In my Swift App (using 3.0), I am trying to check if Google Maps is installed on the phone. If yes, open this address in Google Maps.
UIApplication.shared.canOpenURL(NSURL(string:"comgooglemaps://")! as URL)
Even though I have Google Maps installed, the expression evaluates to false.
Oddly I can open Google Maps in Swift with this
UIApplication.shared.open(NSURL(string:
"comgooglemaps://?saddr=&daddr=\(lat),\(lon)&directionsmode=driving")! as URL, options: [:], completionHandler: nil)
Was there some kind of change in iOS 10.2.1 that prevents the first expression from evaluating to be true?
The URL seems to be the same (comgooglemaps)
Is there something required now in the plist?
To download Google Maps for iPhone or iPad, make sure your phone or tablet is on iOS 13.4 and above. Download the latest version of the Google Maps app in the Apple App Store.
A new version of Google Maps for iPhone and CarPlay is now available for download from the App Store, bringing the app to build 6.16.
If you find Google Maps being slow, not opening or crashing, reboot your device and try to use Google Maps again. Go to Settings > General > scroll down and tap on Shut Down. On the next screen, use the Slider to Power OFF iPhone. After 30 seconds, restart iPhone and check if Google Maps is now working properly.
What you are implementing is legal, but you have to add the URL schemes to the application info.plist, by adding LSApplicationQueriesSchemes array and appending "comgooglemaps" to it:
LSApplicationQueriesSchemes (Array - iOS) Specifies the URL schemes you want the app to be able to use with the canOpenURL: method of the UIApplication class. For each URL scheme you want your app to use with the canOpenURL: method, add it as a string in this array. Read the canOpenURL: method description for important information about declaring supported schemes and using that method.
It should be -somewhat- similar to:
For more information, you might want to check the documentation (mentioned above).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With