I am trying to check if a user has installed a couple of apps. I need it to work on ios9 and ios 10.
I am testing on ios9 first and the schemeAvailable
func is returning true even though the app passed
is not installed on the device.
func schemeAvailable(scheme: String) -> Bool {
if let url = URL(string: scheme) {
return UIApplication.shared.canOpenURL(url)
}
return false
}
I have added the following to my info.plist i.e. the apps I will check are installed:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>app1</string>
<string>app2</string>
</array>
and in my project's info tab, I have added 2 url types and inserted the identifier and url scheme for each.
It sounds like you do NOT have all registrations correct. Your App1 and App2 each need URL Identifiers and Schemes, and your app that "wants to launch App1 and App2" must have
LSApplicationQueriesSchemes
defined.E.G.
This is in "App1"
This is in "App2"
This is in "LauncherApp"
Then, in "LauncherApp" I can do:
You don't have to add the other apps' schemes on your app plist. If you do that you app becomes the responder to URL with that scheme and always be true.
canOpenURL method is not marked as deprecated on documentation
I copy a snippet with part of the code I use to open app url by custom schemes...
And here's an example. I try to open twitter app, and if not presented, open Safari and shows the twitter web page.