Sample code:
let url = URL(string: "https://qiita.com")!
guard UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url, options: [:], completionHandler: nil)
-** In iOS 14.0 / 14.0.1, when the default browser is set to something other than Safari (Chrome, etc.) and the above code is executed, the browser does not start. ** ** -** Even if you build with Xcode 11 (iOS 13 SDK), it occurs on iOS 14 devices. ** ** ――The fact that it has occurred since 14.0 but has not been resolved in 14.0.1 means that it is not a bug in iOS but a specification change?
Procedure to change the default browser to Chrome
If you set the default browser to something other than Safari (Chrome, etc.) on iOS 14.0 or later, ** ʻUIApplication.shared.canOpenURL () `returns false. ** **
** This can be avoided by setting "https" and "http" in LSApplicationQueriesSchemes in Info.plist. ** **
In iOS 14, you can also change the default mailer. ** Similarly for "mailto" **, if you do not add it to LSApplicationQueriesSchemes, ʻUIApplication.shared.canOpenURL ()` will return false if the default mailer has changed.
The above information is useful information obtained from the "Reference Link" article at the end of the sentence. I would like to express my deep gratitude to the authors.
On the other hand, the following is the result of my own additional research.
"tel" is documented in Apple URL Schemes It is a scheme that is. "telprompt" is an undocumented scheme.
Both will launch the Phone app on iOS 14 without adding them to the LSApplicationQueriesSchemes.
By the way, I was wondering "What if I could change the default of the phone application in the future?", So when I added "tel" to LSApplicationQueriesSchemes, it works fine even if I add it (naturally?).
Undocumented scheme. The Wallet app will launch on iOS 14 without adding it to the LSApplicationQueriesSchemes.
This scheme is ʻUIApplication.openSettingsURLString` instead of a string, but (of course) the Settings app will launch on iOS 14 without adding it to the LSApplicationQueriesSchemes.
--In iOS 14, in addition to the custom scheme, ** you have to define the scheme of the app that can change the default in Info.plist. ** ** --Neither the documented scheme nor the undocumented but working scheme ** seems to be affected except by the browser and mailer at this time. ** **
[IOS14] CanOpen URL becomes false when changing the default browser What to watch out for for iOS 14