Launch Safari from app on iOS 14 when Safari is not the default browser using the scheme of the URL
Asked Answered
G

2

11

In iOS 14, Apple has launched the feature to set any browser as default browser which is a nice feature.

If you start a local iOS app from a browser to do some action and then leave the control back to the browser you have to explicitly launch that specific browser on iOS.

To launch the default browser use https://example.com. If the user isn't using the default browser, different vendors have registered schemes to launch them, so if the browser is chrome, you use googlechromes://example.com, if it is firefox use firefox://example.com.

I cannot find how to do this for safari using a safari scheme?

You can of course use the Back-to-app functionality, but the user experience would not be very good.

Grope answered 18/9, 2020 at 6:47 Comment(2)
I found a suggestion in another post, but it's a bit hacky. #57495815Grope
That suggestion is for macOS, it won't work on iOS due to the lack of shell on iOS without jailbreakArteriovenous
T
0

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.

Tyr answered 9/12, 2020 at 4:2 Comment(0)
C
0

Apple has not offered any public URL scheme that would directly launch Safari.

I have not used the Chrome or Firefox schemes myself, but lets assume they work, in contrast, Safari cannot be directly accessed by URL in this way.

There could be people that know bundles that can see if Safari is built for this, but Apple would likely create its usage as a "private API", the way the Settings.app URL scheme is also prohibited in apps.

(There might be a programatic path via "open", but someone knowledgable on that possibly could write another answer).


When the user assigns the default browser, it's just like any desktop / laptop OS. The OS will send the http: and https: URLs to the default browser (and in detail, probably a number of other URLs like ftp:, etc. as well as being the default handler from random-scheme: URLs)

This happens by the OS launching Safari.app. When this happens, the back-app (label-button) appears in the status bar.

For developers, there are several frameworks that are available so you can keep the web loading event inside your app, via WebKit and a Safari Services.

Choroid answered 10/3, 2023 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.