CanOpenURL not working in ios 10

The above code always returns false

if {(UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!))} 

I assume this is a problem discovered in iOS10. I am trying to open the Google Maps application if there is one installed or try to open Apple maps, so you need to use canOpenURL. are there any alternatives

+3
source share
2 answers

Add this to your Info.plist, and then try calling canOpenURL.

 <key>LSApplicationQueriesSchemes</key> <array> <string>comgooglemaps</string> </array> 
+13
source

Edit:

The correct key to be used in the plist file is LSApplicationQueriesSchemes , not the UIDefaultLaunchStoryboard , as indicated in the Apple documentation.

Original answer:

From the Apple documentation:

If your application is connected to or after iOS 9.0, you must declare the URL of the scheme that you want to pass to this method. Do this using the UIDefaultLaunchStoryboard Array in your projects Xcode Info.plist file. For each URL scheme that you want your application to use this method, add it as a string in this array.

If your application (iOS 9.0 or later) calls this method using the scheme you are not declared, the method returns false, regardless of whether the corresponding application for the scheme is installed on the device.

Learn more about this here .

+3
source

Source: https://habr.com/ru/post/1207001/


All Articles