Force open app using Apple Universal Linking

9.1k views Asked by At

I have Universal Linking setup in my app.

Now when browsing my website in Safari and visiting a UL registered link, it opens in safari and asks me if I want to open in my App.

Is there a way that it always opens in the app? No prompt to open in app, just open when it is installed, else continue in safari.

1

There are 1 answers

6
Alex Bauer On

There are two different issues here:

1. In Safari, the URL of a Universal Link needs to be on a different domain/subdomain than the page on which it appears

Apple is very conservative with where Universal Links are allowed to work. One of the limitations in Safari is not allowing the app to open if the user is already browsing the same site (this sort of pages sense — if the user made the effort to open a site in Safari instead of the app, it could be annoying if every single link on that site tried to open the app, especially if the app isn't properly configured for deep link routing).

The workaround is to use a separate domain/subdomain for links you want to open the app. For example, if your site is on example.com, point any link you want to open the app to link.example.com and then redirect users without the app back to the main website or onward to the App Store. This is actually the system we built at Branch.io (which you could consider using instead of re-building it yourself!)

2. What you have described is not Universal Links behavior

Universal Links do not ask the user for confirmation before opening the app, even the first time. They always open the app immediately without even requesting the web page, until/unless the user explicitly disables them (which is actually rather easy to do). What you're describing is the behavior of custom URI schemes, so I suspect you may have a some sort of automatic redirect to the app's URI scheme on the page the Universal Link points to. This is actually not the best idea in most cases, since users without the app will see a nasty error message.