Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

canOpenURL not working in ios 10 [duplicate]

The above code is always returning false

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

I guess this a problem found in iOS10. I am trying to open google maps app if there in one installed or try to open apple maps so wanted to use canOpenURL . are there any alternatives

like image 576
datta kadiyala Avatar asked Oct 18 '16 23:10

datta kadiyala


2 Answers

Edit:

The correct key to be used in the app's plist file is LSApplicationQueriesSchemes and not UIDefaultLaunchStoryboard as stated by Apple's documentation.

Original answer:

From Apple's documentation:

If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by using the UIDefaultLaunchStoryboard array in your Xcode project’s Info.plist file. For each URL scheme you want your app to use with this method, add it as a string in this array.

If your (iOS 9.0 or later) app calls this method using a scheme you have not declared, the method returns false, whether or not an appropriate app for the scheme is installed on the device.

You can read more about it here.

like image 23
Mihai Fratu Avatar answered Oct 26 '22 09:10

Mihai Fratu


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

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>comgooglemaps</string>
</array>
like image 64
Dylan Briedis Avatar answered Oct 26 '22 11:10

Dylan Briedis