Arrangement of the problem that canOpenURL becomes false when changing the default browser / mailer on iOS14 and horizontal deployment survey results

Prerequisite environment

Problem event

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

  1. Install Chrome on your iOS 14 device.
  2. Select Settings> Chrome.
  3. A list of browsers will be displayed, so select Chrome

Cause

If you set the default browser to something other than Safari (Chrome, etc.) on iOS 14.0 or later, ** ʻUIApplication.shared.canOpenURL () `returns false. ** **

Workaround

** This can be avoided by setting "https" and "http" in LSApplicationQueriesSchemes in Info.plist. ** **

Related events

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.

Horizontal deployment survey

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.

Phone app "tel" and "telprompt" schemes

"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?).

Wallet app "shoebox" scheme

Undocumented scheme. The Wallet app will launch on iOS 14 without adding it to the LSApplicationQueriesSchemes.

Settings app

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.

Organize verification results

--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. ** **

Reference link

[IOS14] CanOpen URL becomes false when changing the default browser What to watch out for for iOS 14

Recommended Posts

Arrangement of the problem that canOpenURL becomes false when changing the default browser / mailer on iOS14 and horizontal deployment survey results
[IOS] canOpenURL becomes false on iOS14