Skip to content

Instantly share code, notes, and snippets.

@felquis
Last active November 13, 2024 22:30
Show Gist options
  • Save felquis/a08ee196747f71689dcb to your computer and use it in GitHub Desktop.
Save felquis/a08ee196747f71689dcb to your computer and use it in GitHub Desktop.
iOS, Android browser apps URL Schemes to handle URL between browsers, and apps..

Assume the user is on a mobile device iOS Safari (Or other browser), but you want a link to open into any other specific mobile browser app like Chrome, Safari, Firefox, Opera, Arc... How do you do that?

Chrome

To open on Chrome

<a href="googlechrome://example.com">try it on Chrome</a>

check out Chrome iOS Docs for more information

Firefox

To open on Firefox

<a href="firefox://open-url?url=http://example.com">try it on Firefox</a>

Check out Firefox Docs for more information

Opera

To open on Opera

<a href="opera-http://example.com">Try it on Opera</a>

Check out this page for more information, I couldn't found official Opera Documentation

In-App browsers

Assume the users is on an in-app webview or any other browser, but an API is not support in-app browser, so you need to link the user to Safari, how do you achieve that?

Safari?

I couln't find a URL Scheme for Safari, tried safari://url but it didn't work, it will be handled by Safari.

I filled a bug on Safari webkit about this

I tried x-web-search but it didn't work

People have mentioned com-apple-mobilesafari-tab:https://google.com at redit

Demo and resources

Codepen Demo, Inter App Communication, Apple URL Schemes, I think registerProtocolHandler is somewhat related.. I think this bug is also somewhat related, cause there's developers trying to figure out if a URL Scheme is available in the platform, check out this Stackoverflow question

For Android I found intent Doc, this blog post is insightful, other insightful read was this starckoverflow question "Firefox for Android does not launch app when link is clicked" and URL "Scheme: How can I create a link, which will open a document in the Google Drive app"

Standards

Should we work on a standard way to share information between web apps to installed application and installed application to web apps and web apps to web apps, on desktop, tablets and smartphone?

There's basic necessities when developing a rich web app.

  1. What are the apps the user can share this piece of information?

    Whatsapp has the whatsapp:// URL Scheme, but there's no way to check if the given URL Scheme is available in the platform

    If the user clicks in share, the browser/platform should give a list of applications/web apps the user can share the given information, it could be a URL, String, File Buffer would be great, for example.. The user apply a custom filter to an image on a web app... So the user wants to share it on Instagram.

  2. Is a specfic URL Scheme available?

    There's no standard way to check if a URL Scheme is available

  3. How can I offer my web app the oportunite to the user share the information?

Android has a popup where the user choose where he wants to share the information, a URL or String.. or a image base64 enconded.. So... If my web site provide a way to share images, strings and links.. How can I tell the device/browser my web app can share this kind of information?

I found out the best reading these days is this blog post about a failed Web API called Web Indents, follow all the links

Thank you for reading, I appreciate your help.

@47vigen
Copy link

47vigen commented Nov 25, 2021

any solution yet?

@felquis
Copy link
Author

felquis commented Aug 18, 2022

2022 it is still not possible to target specific browsers apps to handle a link

@PigCharid
Copy link

Do you have an answer? I have such needs now.

@filecage
Copy link

filecage commented Mar 8, 2023

There won't ever be a way to check whether a URI scheme is supported or not; it is a privacy concern, because third party apps could use this information to build fingerprints or just to see what applications are installed on a device (and maybe even detect vulnerable setups).

@wb-towa
Copy link

wb-towa commented Mar 22, 2023

in my iOS bookmarking app, I've simply added the url schemes for a reasonable set of popular browsers (and Jayson). It's less than ideal and it means if someone changes their default there is no way to target Safari.

At worst can't they offer a way for an app to offer itself as a browser and it gets put into a list and the user can grant permission to read that list? It would be nice to be able to target Safari specifically. I've had users that would like that rather than having Safari as their default and selecting the other browser the majority of the time.

@felquis
Copy link
Author

felquis commented Apr 1, 2023

@wb-towa @filecage @PigCharid just updated with a mention to com-apple-mobilesafari-tab:https://google.com, not sure if it's com-apple-mobilesafari-tab://https://google.com or com-apple-mobilesafari-tab:https://google.com, haven't tested it yet. Let me know if that works for you.

@wb-towa
Copy link

wb-towa commented Apr 2, 2023

Thanks @felquis On iOS 16.4, it brings up the dialog asking if I want to open it in Safari but when it's in Safari it fails saying it's an invalid address.

I've tried it without the https:// as well.

It might be they closed off access to this or changed it. When I have more free time I'll see if I can get it to work.

@ilhampsya
Copy link

Any updates about this?

@ericgoodkid
Copy link

Curious also if there's an update with this.

@yosun
Copy link

yosun commented Jun 15, 2024

On iOS 17.5 com-apple-mobilesafari-tab:
leads to
Error Domain=NSOSStatusErrorDomain Code=-10814

@Alex1989Wang
Copy link

x-safari-https://

@yosun
Copy link

yosun commented Jul 17, 2024

@Alex1989Wang which xcode/ios version does that work with?

@Alex1989Wang
Copy link

I am using XCode 15.4 and iOS 18 beta. But this was suggested by someone quite some time ago. Should work with other iOS versions.

@wb-towa
Copy link

wb-towa commented Jul 17, 2024

Apparently not iOS 16. https://christiantietze.de/posts/2023/05/safari-for-mac-url-scheme/

This does work right now on my iPhone but my fear is it won’t always work.

@Alex1989Wang
Copy link

@neestzjov
Copy link

How to make the link opened on iOS to use default browser rather than specific safari or chrome?

In-app Instagram Link -> Default Browser (user preference)

Just like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment