So I have the following apple-app-site-association on my site, located at stage.domain.com/apple-app-site-association
:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TEAMID.application.id.goes.here",
"paths": ["*"]
}
]
}
}
I've set my Associated Domains as applinks:stage.domain.com
But when I try to navigate to stage.domain.com
in Safari, it doesn't register and I stay in the browser. Is there anything else I need to do? I know that I need to eventually set routing up in the app for various pages, but that isn't a necessary requirement is it? It should just pull up the app without anything else? Or am I missing something?
Also, my restoration handler:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
print("DEBUG GETS TO NSURL?")
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL
else
{return false}
print("DEBUG GETS TO URL")
return true
}
It gets to neither debug condition.
By definition, Universal Links do not work when they are redirected from another URL. This limit is meant as a security measure, preventing a website from opening apps without explicit user intention.
TEST THE UNIVERSAL LINKS Run the application on the simulator once to make sure the application is installed and running fine. 2. Keep the same simulator launched and running. Go to your simulator browser and open type the ngrok domain address i.e., https://1bd39880fbad.ngrok.io in my case.
Did you already go through the debugging steps here: https://developer.apple.com/library/content/qa/qa1916/_index.html
I found the validation tool linked to in step one of the diagnostic section of the above reference to be quite helpful. It will verify that you set the app association file up correctly, and often give some guidance if you didn’t.
Based on your comment below regarding the link not working in Safari, I'd suggest verifying that your universal link setting for that domain didn't get disabled on your test device.
Specifically:
If a user opens a universal link and is taken to the app, there is a shortcut in the top right of the status bar which, if tapped, takes the user to the web version of the link and also disables the universal link opening the app. To re-enable the universal link for your app, you can paste the link into an app like Notes or Messages, long press on it, and choose "Open in... [Your App]".
The other possibility is that your web page in Safari is trying to open the universal link via Javascript or wrapped in a redirect. Neither of these will work.
There are more details in this blog post, along with some other universal link issues: https://medium.com/mobile-growth/the-things-i-hate-and-you-should-know-about-apple-universal-links-5beb15f88a29
I have a suspicion regarding your scenario: Apple does not trigger a universal link when the user directly types a URL to a universal link domain into the Safari address bar. The assumption being that if the user explicitly entered a URL into the Safari address bar, the correct response is to open the URL in Safari. In this scenario, Safari inserts the banner that allows the user to intentionally open the link in the app to the top of the page.
You can test this yourself:
If, when you access your site, it shows the universal links banner on top of the page, like this: https://i.stack.imgur.com/ZSQGK.jpg, you are doing it right.
If you click on Open, it should open the app. Then, if you try to click on a link to your website AFTER you opened your app through the banner, iOS should save your preferences and open the app directly, instead of going to Safari with the banner on top.
The way Universal Linking works, it does not allow the app to be opened by links without any consent of the user. Thus, the user must give permission at least one time before the app opens automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With