I find it weird that though canOpenURL(myURL) is false while open(myURL) perfectly redirected to the app I want. What am I doing wrong here?
override func viewDidAppear(_ animated: Bool) {
let instagramUrl = URL(string: "instagram://app")!
print(UIApplication.shared.canOpenURL(instagramUrl)) // false
if UIApplication.shared.canOpenURL(instagramUrl) {
UIApplication.shared.open(instagramUrl, options: [:], completionHandler: nil)
} else {
UIApplication.shared.open(URL(string: "http://instagram.com")!, options: [:], completionHandler: nil) // Instagram successfully launched???
// UIApplication.shared.open(instagramUrl, options: [:], completionHandler: nil) // This works too
print("Open failed.") // Open failed.
}
}
Console:
-canOpenURL: failed for URL: "instagram://app" - error: "This app is not allowed to query for scheme instagram"
[MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
[MC] Reading from public effective user settings.
My Info.plist as below