From episode "5 - Setting Up Universal Links (Deep Linking)" on the Inside iOS Dev Podcast
1) Create an apple-app-site-association file that contains JSON data about the URLs that your app can handle.
- Create
apple-app-site-association
text file without.json
file extension - Use
application/json
MIME type for the text file - Have the following contents of the file similar to this format:
{ "applinks": { "apps": [], "details": [ { "appID": "9JA89QQLNQ.com.apple.wwdc", "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"] }, { "appID": "ABCD1234.com.apple.wwdc", "paths": [ "*" ] } ] } }
- “apps” key must contain an empty array
- Adjust the contents in “details” key as necessary (see this apple doc for reference)
2) Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory.
- Make it publicly available (with no redirects or 40x) under
mywebsite.com/apple-app-site-association
- You don’t have to encrypt the AASA file if it’s served over HTTPS to iOS >=9.0. Otherwise, you will need to encrypt it.
- Add an entitlement that specifies the domains your app supports. (Add them in format:
applinks:www.mywebsite.com
applinks:mywebsite.com
applinks:subdomain.mywebsite.com
) - Update your app delegate to respond appropriately to
application(_:continueUserActivity:restorationHandler:)
. Receives anNSUserActivity
object. If activityType isNSUserActivityTypeBrowsingWeb
, then that means it was Universal Link. Access thewebpageURL
property to receive NSURL user tapped on.
- https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html
- https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9/
- https://www.raywenderlich.com/128948/universal-links-make-connection
- Use Apple AASA validator online. https://search.developer.apple.com/appsearch-validation-tool
- The AASA file is downloaded every time you installed your app. So, uninstall/install to redownload the AASA file after changes are made to it.
- If you long press on a link and select to Open in Safari then Apple will remember that choice and default to opening in Safari. So you’ll have to long press link again and choose your app to make that the new default.
Thank you, this is very helpful.