You might think it's a duplicate question, but it's not, I'm totally aware of all the answers on SO about the canOpenURL
and its caveats on iOS 9, but here is my problem:
I'm trying to check if an specific app is installed on my device (both developed by me).
I have declared the scheme on AppA
as:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.my.company.id</string>
<key>CFBundleURLSchemes</key>
<array>
<string>XYZ</string>
</array>
</dict>
</array>
and on the other app, AppB
I have added in info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>XYZ</string>
</array>
Now, in AppB
I'm trying to find out if I have AppA
installed like this:
internal static let appAScheme = "XYZ://"
static func AppAInstalled() -> Bool {
let appAURL = NSURL(string: appAScheme)
return UIApplication.sharedApplication().canOpenURL(appAURL!)
}
It always returns
-canOpenURL: failed for URL: "XYZ://" - error: "This app is not allowed to query for scheme XYZ"
How ever, If I try to open AppA
from AppB
it'll work with no problem!
// Works alright
UIApplication.sharedApplication().openURL(appAURL!)
I can't figure it out why!