1. Use
The Universal Link is one of the new iOS9 features apple announced at WWDC. This feature is similar to deep linking and makes it easy to launch your client application directly by opening an Https link (the phone has the App installed). This new feature provides an excellent user experience in achieving seamless web-app connectivity, compared to the URL Scheme used in the past.
When your APP supports Universal Link, when users click on a Link they can jump to your website and get a seamless redirect to the corresponding APP, without using Safari. If your app doesn’t support it, it will open the link in Safari.
2. Configure the developer center
Go to the Developer Center, find your appID in the Identifiers, and check Associated Domains.
3. The Xcode configuration
In Xcode, add Associated Domains in singing&abilies. In Domains, add applinks:www.xxx.com and www.xxx.com are company domain names. You can add more than one.
4. Configuration apple – app – site – association
Refer to the website developer.apple.com/library/arc… .
{ "applinks": { "apps": [], "details": [ { "appID": "9JA89QQLNQ.com.apple.wwdc", "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"] }, { "appID": "ABCD1234.com.apple.wwdc", "paths": [ "*" ] } ] }}
Copy the code
Write an apple-app-site-association file with the content above, without adding a suffix.
The appID here is Team ID.buliDID.
TeamID can be viewed inside Membership.
Paths are allowed to jump, for example www.xxx.com/wwdc/news…
"paths":["NOT /test/*", "/*"]
Copy the code
Adding NOT means that the suffix is NOT allowed to jump, and * means that all links are fine.
5. Upload the server
Upload the apple-app-site-association file to the root directory or well-known domain name server (HTTPS) of your domain name server. Just write it in the background and ask them to upload it. This is a request for validation to the Apple server.
Open the validation website: search.developer.apple.com/appsearch-v…
If yes, the configuration is successful.
6. Test common links
1. Enter your own link to www.xxx.com in the memo.
If you open it in your own app, you can jump to your app.
2. Open your own link in Safari and swipe up and down. If you see it open and jump to the APP, it also means success.
7. Code judgment links
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler { if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) { NSURL *url = userActivity.webpageURL; Else {[[UIApplication sharedApplication] openURL:url]; else {[[UIApplication sharedApplication] openURL:url]; } } return YES; }Copy the code
When another APP, or H5 page, calls to our APP, continueUserActivity can be used in this method.