7

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.

Robert Broersma
  • 790
  • 1
  • 7
  • 24
  • I believe it has to ask the first time but from then on it will always open? – Sean Lintern Dec 22 '16 at 10:18
  • @SeanLintern88 I believe so as well. But I'd like it not to ask first, like on android, since I redirect all my UL to a standard page, therefore the prompt is lost when it continues in Safari. If it's not possible I'll have to look for a different solution :) – Robert Broersma Dec 22 '16 at 10:20
  • I don't think it is. Apple basically gives the user a choice if he would like to continue using Safari, or switch to native app. – Losiowaty Dec 22 '16 at 10:54
  • @Losiowaty First time Apple gives me a choice and now I don't want it. – Robert Broersma Dec 22 '16 at 11:40
  • Universal Links do _not_ ask the user the first time. They just open the app immediately 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. Can you give more detail on your configuration? – Alex Bauer Dec 22 '16 at 15:06
  • 1
    Also, note that if you're browsing in Safari, the Universal Link must be on a different domain from the page on which it appears in order to open the app. – Alex Bauer Dec 22 '16 at 15:07
  • @AlexBauer This is my problem exactly. I'm browsing on my own website, when I hit a page that I want to open in my app, I want it to open the app, not continue in Safari. – Robert Broersma Dec 22 '16 at 15:32
  • Then you'll need that link to be on another domain. Design limitation from Apple – Alex Bauer Dec 22 '16 at 15:34
  • @AlexBauer Would a different subdomain also work? i.e. link.example.com vs example.com – Robert Broersma Dec 22 '16 at 15:35
  • Yes indeed. That's actually the best solution – Alex Bauer Dec 22 '16 at 15:39
  • Alright. Might try that. Thanks all! – Robert Broersma Dec 22 '16 at 15:49

1 Answers1

15

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.

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44
  • 1
    1 is completely true. 2 is not, I have no URI Scheme at play whatsoever. I believe the smart banner does appear when you are browsing on the same domain, or at least you can pull it down. – Robert Broersma Dec 23 '16 at 08:21
  • Hmm. I have never seen that. Could you give example links or a video of it occurring? – Alex Bauer Dec 23 '16 at 15:46
  • Great answer Alex. But in the above scenario which domain do you have to host the apple-site-links-association file? I would assume that also needs to be on link.example.com? – stueynet Oct 04 '17 at 23:52
  • 1
    @stueynet yes that's it! The AASA file goes on the domain of the URL of the link. – Alex Bauer Oct 05 '17 at 01:00
  • For app to open directly, the url must have been visited earlier. If even a single character is changed in url then the popup will appear again? This is happening with me right now as my path parameters keep on changing. Any solution to this? – Navneet Gill Apr 06 '18 at 12:24
  • This `app.link` service no longer opens appstore on iPad's with Safari 13 if you don't have the app. I bet because it's acting like it's Mac OS X Safari. – odinho - Velmont Apr 17 '20 at 11:18