I'm trying to open Amazon app from within my app using following code:
if let url = URL(string: "amzn://"),
UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else if let url = URL(string: "https://www.amazon.com") {
// fallback
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
This worked like a charm when I used it for the Youtube app. However, now with Amazon it just silently fails while it reports this error:
2018-10-11 10:38:09.794370+0200 App[9739:3023026] -canOpenURL: failed for URL: "amzn://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
I've added url scheme to LSApplicationQueriesSchemes
in Info.plist
, but this changed nothing:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>amzn</string>
</array>
What is even weirder, it does not even open the fallback URL - I would expect that if the canOpen
fails, the second branch would work.