canOpenURL returns false when I changed the default browser on iOS 14

I used canOpenURL like this:

Code Block
UIApplication.shared.canOpenURL(URL(string: "https://developer.apple.com/")!)


It was true when I set Safari as a default browser.
But I changed it to the other browsers like Chrome and Edge, then it was false.

Adding https & http into LSApplicationQueriesSchemes, it was the result I had hoped for.

Is this a bug or a correct behavior for iOS 14?

(iOS 14 Beta 8)
  • This worked for me, even on 14.2

Add a Comment

Replies

Facing the same question.
Will got this:
Code Block
-canOpenURL: failed for URL: "https://developer.apple.com/" - error: "This app is not allowed to query for scheme https"


I think its a bug.
Both my app and the default browser have access to https.

Post not yet marked as solved Up vote reply of iwpz Down vote reply of iwpz
Same Issue with GM seed.
Same error. Do you think we can rely on Apple to release a change to become backwards compatible? Or will everyone have to add the https and http schemes to all their apps so that they will still work?
Hello,

I am working on QR app which generates QRs also for websites and I had the same issue when generating URLs, including adding https to LSApplicationQueriesSchemes worked for me.

iOS 14, Xcode 12.0.1 (12A7300)
Facing the same issue but only when :
  1. the default browser is chrome,

  2. and OpenUrl API is called from the .framework (static library)

In case of safari as default browser it works fine, even if I call OpenUrl API from within Framework. (Strange!!)

If I make chrome as default browser and call OpenUrl API from the main app (App that is integrating the framework) it works!!

Did anyone got the answer for this behaviour?


Has anyone found a way to resolve this problem by chance?
  • edit: Sorry didn't realize to most recent answers were on top. Adding this to my info.plist worked for me

Thanks Petr - RoxiVPN

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>https</string>
  </array>
What is more strange is if I don't do a canOpenUrl check and just call openUrl directly it will open chrome as expected.

Does not work as expected:
Code Block
if UIApplication.shared.canOpenURL(url) { // returns false if Chrome is default browser
UIApplication.shared.open(url)
}


Omitting the canOpenURL check successfully opens chrome.
Code Block
UIApplication.shared.open(url) // opens chrome



Any update on this? Or is everyone expected to add http and https to their plist?


I think this issue has been fixed in iOS 14.4
Post not yet marked as solved Up vote reply of bdar Down vote reply of bdar

iOS 14.6 Xcode Version 12.5.1 (12E507) some https url canOpenURL false can not jump open Safari, WKWebView can load url