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
The correct key to be used in the app's plist file is LSApplicationQueriesSchemes
and not UIDefaultLaunchStoryboard
as stated by Apple's documentation.
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.
Add this to your Info.plist and then try calling canOpenURL.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
</array>
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