canOpenURL not working in ios 10

datta kadiyala picture datta kadiyala · Oct 19, 2016 · Viewed 7.4k times · Source

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

Answer

Dylan Briedis picture Dylan Briedis · Oct 19, 2016

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

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>comgooglemaps</string>
</array>