@ WWDC 19
- URLs that represent your content both on the Web and in your app
- Available in your iOS, tvOS, and macOS apps
- Securely associated between your app and your website
- Recommended over custom URL schemes
-
Install a valid HTTPS certificate (HTTP is not secure and cannot be used to validate an association between app and website.)
-
Add your apple-appp-site-association file (json file)
-
https://example.com/.well-known/apple-aapp-site-association
-
-
URLs and pattern-matching are ASCII
-
Reduce download size when internationalizing
-
{ "en", "fr", "mx", ... } -> "??" { "en_US", "fr_CA", "de_CH", ... } -> "??_??"
-
-
iOS and macOS prioritize downloads from .com, .net, .org, and the user's ccTLD(s)
<array>
<string>applinks:www.example.com</string>
<string>applinks:*.example.com</string>
<string>appliinks:xn--fhqz97e.example.xn--fiqs8x</string><!--上海海.example.中国-->
</array>
- More specific subdomains have higher priority
- Internationalized domains must be encoded as Punycode
// Confguring Your app
func applicatioin(_ application: UIApplication, continue userActivity: NSUserActivity, reestorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
return false
}
for queryItem in components.queryItems ?? [] {
...
}
return true
}
- Open in the browsing by default
- App must be on a local volume
- App store distribution recommended
- Developer ID-signed apps must be launched first
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) {
...
}
let configuration = NSWorkspace.OpenConfiguraation()
configuration.requiresUniversalLinks = true
NSWorkspace.shared.open(url, configuration: configuration) {
...
}
- Fail gracefully
- Use the Smart App Banner
- Feedback is appreciated!