6

I have two build configurations: App and App Stage.

Each configuration has different Associated Domains configured: app.mydomain.com and app-stage.mydomain.com.

Of course, each website exposes different apple-app-site-association files: app.mydomain.com/apple-app-site-association and app-stage.mydomain.com/apple-app-site-association (HTTP 200, without .json extension, etc.).

The problem is that only first registered domain (unfortunately it's Stage) is working properly. When I have both apps installed, each deep link (app.mydomain.com/home and app-stage.mydomain.com/home) opens the App Stage. When I have only App Sage installed, also both links open it. When I have only App installed none link is working. It looks like the subdomain of Associated Domains is ignored and only mydomain.com is taken into account.

I assume that build configurations are defined correctly because I'm also differentiating other settings like Facebook, Google and others.

Have you ever encountered a similar problem? Is it allowed to use different subdomains of the same domain for the Associated Domains usage?

UPDATE:

Following @clayjones94 instructions, I checked whether each app downloads a correct JSON file using Charles Proxy. I found out that that App Stage is fetching the correct file, while App doesn't fetch any file.

I have also edited URL in app-stage.mydomain.com/apple-app-site-association HTTP request in Charles to make sure that app.mydomain.com/apple-app-site-association returns the correct JSON. When I removed -stage from the URL and repeated the call it has fetched a different JSON file, so I confirmed that the backend is working correctly for both configurations.

First I thought that my build configurations were incorrect. So I decided to replace App's applinks:app.mydomain.com associated domain with Stage's applinks:app-stage.mydomain.com to see if App configuration is able to fetch App Stage file. It worked, the App had downloaded App Stage's JSON file. Again, it looks like the subdomain of Associated Domains is ignored and only first registered subdomain is taken into account.

KlimczakM
  • 11,178
  • 10
  • 55
  • 76
  • Can you see your access logs on your server to see what is being requested? Does `mydomain.com/apple-app-site-association` serve anything? – Lou Franco Dec 20 '17 at 15:44
  • Yes, it can be fetched with success (HTTP 200) and it looks almost the same as the stage subdomain `apple-app-site-association` file - only the bundle identifier is different (both apps are in the same team). – KlimczakM Dec 20 '17 at 15:47

2 Answers2

2

There is nothing like domain & subdomain concepts when it comes to Universal Links (App Domains).I guess there should be an issue with apple-site-association-file configuration.

Please check the apple-site-association-configurations regarding the appID field. I doubt that you might have placed the same appID in both files.

you should have different appIDs for the two configurations.

Kumar Reddy
  • 736
  • 6
  • 15
  • Thank you for your reply. The `apple-app-site-association` files differ, Stage App appID entry: `"appID": "3U******2D.de.k****a.app-stage"`, App appID entry: `"appID": "3U******2D.de.k****a.app"`. I hope it's not an iOS bug, like the one with silent notifications on iOS11... – KlimczakM Dec 20 '17 at 16:57
  • do you have any other associated domains listed out there? – Kumar Reddy Dec 20 '17 at 17:05
  • No, this is the only one. – KlimczakM Dec 20 '17 at 18:41
1

When pulling the Apple App Site Association file, your OS should pull both down separately. I recommend deleting both apps and restarting your phone to ensure that no old AASA files are being cached.

When you go to install the apps back onto your phone, you can use Charles Proxy to see whether each installation is pulling the correct AASA file. Since you have both URLs in your associated domains, each installation is going to pull down both AASA files. If your production app is not pulling down both it could be an Apple issue and you'll just have to delete the app and try again.

If you verify that both AASA files are being pulled down for each app, then you should verify that the appIDs are correct (which it seems like you have). When both apps have both associated domains and both AASA files with the correct appIDs, your OS should open the correct app depending on the link. If this still doesn't work it could mean that your AASA files have been signed by entitlements associated with your Staging app but not your production app.

I suggest using Branch for your universal linking. Branch has testing links that you can use to test links for your prod app and you should be able create a separate app on Branch for your staging app so you have different links for both. The nice thing is that we will do all of the AASA handling and signing for you. The deep linking service is free and we perform deferred deep linking :).

clayjones94
  • 2,120
  • 10
  • 23
  • Thanks for your reply! When I used Charles to verify whether each app is downloading a proper file I found out that while App Stage is downloading the correct file, App doesn't download any AASA file! Now I'm investigating why. – KlimczakM Dec 21 '17 at 07:06
  • Please check updated question. When I used the App Stage associated domain for the App (just added `-stage` to the domain in the Xcode), the App has downloaded App Stage JSON file (previously it wasn't fetching anything). – KlimczakM Dec 21 '17 at 07:36
  • Hmm this shouldn't be the case. Branch apps will actually fetch AASA files from 2 different subdomains. We have a `-alternate` similar to your `-stage` for every app. The alternate domain is used when a user is on original subdomain and wants to deep link into the app (Apple has a restriction of not allowing Universal Links to go to the native app if a user is on that domain). Look at my test apps AASA at http://q1hv.app.link/apple-app-site-association and the alternate AASA at http://q1hv-alternate.app.link/apple-app-site-association. It seems like you App's AASA file is not hosted correctly. – clayjones94 Dec 21 '17 at 18:53
  • Thanks for your example, it convinces me that it shouldn't be the problem and I should keep trying. I'll update the question if I find anything else. – KlimczakM Dec 22 '17 at 16:16