Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if Google Maps Is Installed - iOS 10.2.1

Tags:

ios

swift

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?

like image 568
Ray Saudlach Avatar asked Jan 29 '17 14:01

Ray Saudlach


People also ask

Is Google Maps installed on iPhone?

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.

What is the latest version of Google Maps for iOS?

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.

Why does Google Maps not work on iOS?

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.


1 Answers

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:

enter image description here

For more information, you might want to check the documentation (mentioned above).

like image 69
Ahmad F Avatar answered Oct 06 '22 01:10

Ahmad F