6

I have read a lot of articles regarding universal links but still i need to be clear regarding few things.

I have to add universal links to http://www.domain.com but due to certain reasons i will not be able to make my website SSL certified or even put apple-app-site-association with https in root folder. So I thought of doing this in a different way, i will put apple-app-site-association file in the root of a subdomain, lets say https://www.app.domain.com/apple-app-site-association

Then i will open every universal link with that subdomain whenever universal link is available and redirect https://www.app.domain.com to http://www.domain.com if universal link is not available.

Questions in my mind :-
  1. apple says - file needs to be accessible via HTTPS—without any redirects—at https:///apple-app-site-association. In this line what does apple mean by without any redirects ?

  2. when apple does not find any universal link related to a particular URL, will it itself redirects it to safari.

  3. Is this a safe way to add universal links or is it necessary to have our main domain on https or at-least apple-app-site-association on https
Sudhanshu Gupta
  • 2,255
  • 3
  • 36
  • 74

2 Answers2

5

This should work fine. To explicitly answer your questions:

  1. 'Without redirects' means when iOS requests https://www.app.domain.com/apple-app-site-association, it must find the file at that address. You can't have a redirect of any kind (Javascript, 301, 302, etc)
  2. If a URL is not valid for Universal Links because you didn't cover it using the inclusion rules in the apple-app-site-association file, it will be opened using Safari. If the URL is on another domain without a valid apple-app-site-association file (e.g., http://www.domain.com/), then it will also be opened in Safari.
  3. Yes, it's fine. Definitely a workaround, but not unsafe.

You should also investigate a hosted deep linking service like Branch.io (full disclosure: I'm on the Branch team) or Firebase Dynamic Links. These will give you all of the same benefits (plus a bunch more flexibility, to be honest) without any of the setup headaches.

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44
  • Hi Alex, regarding #1 do you have a source? Where does it say that all kind of redirects are not allowed? – Sorcerer Oct 05 '17 at 12:28
  • 1
    @Sorcerer right here on the official Apple documentation pages: https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html – Alex Bauer Oct 05 '17 at 15:11
  • If you test with a 302 on Apache - it works. Seems like Safari and Chrome on iOS don't care about these kind of redirects. I agree that Apple documentation clearly says "without ANY redirect", but if you test with a 302 it works. – Sorcerer Oct 10 '17 at 15:29
  • @Sorcerer wow, that could be a game changer. Mind sharing your working implementation? – Alex Bauer Oct 10 '17 at 15:56
  • I will write a regular response to this question because the answer is a bit longer. – Sorcerer Oct 10 '17 at 16:04
  • Hi! I have an issue with multiple subdomains: (a.b.domain.com). A single subdomain deeplinks fine and opens the app (a.domain.com) . But a.b.domain.com does not. Both are provisioned exactly the same way through capabilities. Both host an identical apple-app-site-association file. Maybe I should add the apple-app-site-association file to the root of the whole site (domain.com), OR add it to just 1 level of the subdomain (b.domain.com, instead of a.b.domain.com)? https://stackoverflow.com/questions/58665606/ios-universal-link-with-a-2-piece-subdomain-doesnt-open-the-native-app-but-wo – FranticRock Nov 04 '19 at 15:37
1

We experienced ways where a 302 on iOS works. In general I fully agree that Apple officially does not seem to support any redirect. The following cases have been tested on an iPhone 6 running iOS 11.

These cases work :

  • Website in Chrome on iOS: User clicks on link A and a 302 redirects him to a Universal link B.
  • Website in Safari on iOS: User clicks on link A and a 302 redirects him to a Universal link B.
  • Gmail App on iOS: User clicks on link in email and Gmail opens external Chrome browser, which opens a Google link which redirects to link A which redirects via 302 to Universal Link B. (this case works only if Chrome is installed and in Gmail Settings the user explicitly changed the default browser to Chrome)

These cases DO NOT work:

  • Apple Mail: User clicks on link A in email and external Safari is opened. 302 happens and opens Universal link B. Result: App does not open
  • Gmail App: User clicks on link A in email and Gmail inAppBrowser (probably WKWebview?) is opened. Gmail redirects EVERY link from an email over a google server, as a second step link A is opened (dont know via 302 or other method) then 302 happens and opens Universal link B. Result: App does not open

Unfortunately you can see that in some cases it does NOT work. As these cases, Apple Mail and Gmail on iOS are very important for most of us here, I think this is a showstopper and you should not use it.

We tested with Adjust links and therefore in cases where the app does not open Adjust opens the AppStore to download the app.

For all Adjust interested: We tested by opening a link https://app.adjust.com/... which has a 302 on the respective Universal link https://XXXXXXX.adj.st/... on which our app listens.

Sorcerer
  • 854
  • 1
  • 8
  • 20
  • Ahhhh... @Sorcerer, I misunderstood your original point. Yes, these cases are actually well-known, though it's great to see them written out in detail! For some reason, I thought you were talking specifically about the `apple-app-site-association` file, which cannot be behind redirects of *any* kind — a 302 working there would have been major news. – Alex Bauer Oct 11 '17 at 03:34
  • @AlexBauer I think you got it wrong. The last part of my response says, that there is a redirect from https://app.adjust.com/... via a 302 to https://XXXXXXX.adj.st/... which has the apple-association-file. The other domain app.adjust.com does NOT have the association file, so this seems to be a case where a 302 works. Of course only in the outlined cases. – Sorcerer Oct 11 '17 at 13:01
  • Yes, that makes sense. The AASA file is only scraped one time, when the app is first installed. As long as iOS finds that file at XXXXXX.adj.st, everything else works as you describe – Alex Bauer Oct 11 '17 at 13:35