IOS 9 universal link (Universal, Links)

What is Universal Links?

Before iOS9, we usually only used scheme for the need to wake up APP from various browsers and Safari. But this way you need to determine in advance whether or not the system has a app that is responsive to this scheme, and this method is disabled in WeChat.

Universal Links is a function of the iOS9 launch, so that your application can be started by the traditional HTTP link APP (if you have installed app, iOS device in WeChat or no matter where), or open the page (your app is not installed on iOS devices).

The following simple to say how to use Universal Links, specific can see the official documentation

How do I use Universal Links?

1. prerequisite: you must have a domain name, and this domain name needs to support https.

2., you need to configure in the developer center: find the corresponding App ID, in the Application Services list, there is a Associated Domains, and turn it into Enabled on it.

The IOS 9 universal link (Universal, Links)
configuration App ID supports Associated Domains

3. open the Associated Domains in the project configuration, and fill in the Domains in which you want to support the domain name, must be prefixed with applinks.

Associated Domains in the IOS 9 universal link (Universal, Links)
configuration project

4. create a file in JSON format, and Apple will request the file at the right time from the domain name we fill in the project. This file name must be apple-app-site-association, no suffix, and the file content is probably like this:

{{"applinks": "apps": "details": [], [{"appID": "9JA89QQLNQ.com.apple.wwdc", "paths", "/wwdc/news/", "/videos/wwdc/2015/*"]}, {"appID": "ABCD1234.com.apple.wwdc", "paths": [*]}]}}

Explain´╝Ü

AppID: the composition is teamId.yourapp ‘s bundle identifier. As above, 9JA89QQLNQ is teamId. Landing Developer Center, you can find Team ID in Account – Membership. Paths: set the path list for your app support, and only the links of these specified paths can be processed by the app. The asterisk name stands for all links under the recognized domain name.

There are many examples of other companies in this blog, which can be referred to. It is possible that some of the company is no longer applicable, you can change other companies.

5. upload the file to the root directory or.Well-known directory of your domain name, which is for apple to get the files you uploaded. After uploading, visit yourself first and see if you can get it. When you enter this file link in your browser, you should download the apple-app-site-association file directly.

Verification

In the memo in the iOS device, enter the link that App can identify, and then click the link directly, and it will jump to your app directly. Or long press, in the pop-up menu appears, the second item is opened in ‘XXX’, which also represents success:

IOS 9 universal link (Universal, Links)
appears menu

Or the web site you are trying to test opens in Safari and glides over the page that appears. You can see it in the “XX” application:

IOS 9 universal link (Universal, Links)
appears menu

Is in WeChat’s web browser, although WeChat screen jump all scheme to other app, but Universal Links is handled directly by the system, WeChat can not shield it, from the implementation of the WeChat jump into our app.

Apple, in order to facilitate developers, provides a web page to verify that the apple-app-site-association we wrote is valid and valid:

IOS 9 universal link (Universal, Links)
authentication link

Processing after entering app

Now that users click on a link, they can go directly to our app, but our goal is to be able to obtain links to the user and display the content to the user according to the link.
, we need to implement the method in the AppDelegate in the project

- (BOOL) application: (UIApplication * application) continueUserActivity: (NSUserActivity * userActivity) (restorationHandler: (void ^) (NSArray * _Nullable) restorationHandler) if ([userActivity.activityType isEqualToString: NSUserActivityTypeBrowsingWeb]) {NSURL {*url = userActivity.webpageURL; if (URL is our hope to deal with the) {/ / our else sharedApplication] openURL:url] {[[UIApplication} treatment; return YES}}};

Well, first of all, here, if you have any problems, you can see the official documentation in detail.

Welcome to pay attention to me and my topic: iOS technical exchange, check out more good articles.