IOS Universal Links)

Source: Internet
Author: User

IOS Universal Links)
Introduction

What is Universal Links )?
This is a feature launched by iOS9. If your application supports Universal Links ), you can easily start the APP through the traditional HTTP Link (If your app has been installed on the iOS device, no additional judgment is required ), or open the webpage (your app is not installed on iOS devices ). it may be simpler to describe that before iOS9, we can only use scheme to wake up apps from various browsers, Safari, UIWebView, or WKWebView. first, register a scheme in the app, for example

On the webpage,

Open APP
  Open the dial-up to open the system's text message app

However, this method is difficult to determine in advance whether the system has installed an app that can respond to this scheme. There are many online apps, such as awakening apps from browsers or webviews, as described in the article, many web pages may have problems in judgment. There are often blank pages that cannot be redirected. even more sadly, this scheme method is used to open other apps, and is disabled in the middle. this means that from the app, we cannot open our app.

Universal Links: A common http link, for example, success !!! When you have not installed the tool, you can go to the page you specified (you can directly display your original H5 page or jump to the download page ). that is to say, the user does not need to know whether you have installed the app. If you have installed the app, this link can be used to enter the app, you can use a local native page to display information to users.) without installation, you can directly go to the original h5 page. This is a seamless process for users and is very smooth!

Official Instructions

Advantages of Universal Links Uniqueness: Unlike custom scheme, because it uses standard http/https links to your web site, it will not be declared by other apps. in addition, because the schm URL scheme is a Custom protocol, it cannot be directly opened without installing the app, and the universal links itself is an HTTP/HTTPS link, so there is better compatibility Security: When your app is installed on your mobile phone, then iOS will go to your website to download the instruction file you uploaded (this instruction file declares what types of http links can be opened by your app ). because only you can upload files to the root directory of your website, the association between your website and your app is secure. Variable: When your app is not installed on your mobile phone, Universal Links can also work. if you want to, when you do not install your app, you click the link to display your website content in safari. Simple: A url link that can simultaneously act on websites and apps PrivateOther apps can communicate with each other without having to know whether your app is installed or not. How to support Universal Links (general link) Prerequisites:

You must have a domain name, and the website of this domain name must support https, and then have the permission to upload the website to the root directory (this permission is used to upload a file specified by apple)

You can use Universal Links to create an apple-app-site-association file in json format. No suffix is required, The file name must be Apple-app-site-association!!!
{    "applinks": {        "apps": [],        "details": [            {                "appID": "9JA89QQLNQ.com.apple.wwdc",                "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]            },            {                "appID": "ABCD1234.com.apple.wwdc",                "paths": [ "*" ]            }        ]    }}

Note:
AppID: The composition method here is teamId. yourapp's bundle identifier. The 9JA89QQLNQ and ABCD1234 above are all teamids. Where does this value come from?
It comes from the personal center of the developer account and logs on to your Developer Center.

Com. apple. wwdc is your way of teamId. yourapp's, in your xcode Project

Paths:
Set a path list supported by your app Based on the paths key. Only links to these specified paths can be processed by the app. For example, if your website iswww.yohunl.comYour path is written as "/support/*". When you clickwww.yohunl.com/support/myDoucumentYou can access your app. On the contrary, www.yohunl.com/other won't.
Path is case sensitive!
* Indicates any path.

Upload the file apple-app-site-association to the root directory of the website corresponding to your domain name (in fact, it is not necessarily the root directory, such as the ghost blog site, if there is no root directory, it needs to be placed in the corresponding topic directory), this step is for AppleHttps: // your domain name/apple-app-site-associationxH. Obtain the apple-app-site-association file you uploaded.
After uploading, visit first to see if you can get, use my example, https://yohunl.com/apple-app-site-association, When you click this link, it should be to download the apple-app-site-association file.
Verify that the file is legal. apple provides a webpage for developers to verify that the apple-app-site-association we have compiled is legal and valid.

Perform some configuration in the xcode Project
First, open Associated Domains in the project configuration.

Enter the domain name you want to support in Domains (this is not a casual field, it can support the Domain Name of the Universal Links you need ).Applinks:Prefix
For example

applinks:yohunl.comapplinks:www.yohunl.com

The domain name request file apple-app-site-association

Note: After you open Associated Domains, xcode will add the. entitlements file to your project.
If you log on to your Developer Center, you can see
These are all helpful for troubleshooting.

At this point, your app can now support Universal Links !!!
So how can we test it?

Test whether the Universal Links (general link) takes effect

In the iOS device memo, add a notepad or text message and enter a link that the App can recognize. Then, click this link to directly jump to your app.
Or long press. In the displayed pop-up menu, the second item is "Open in 'xxx'", which also indicates success.

Or put the website you want to test on a web page in safari, click the link, and drop down at the top of the page that appears, you can see that it is opened in the "XX" application. (In many tutorials, clicking directly in safari will jump to the app. However, after my actual verification, it is not possible, maybe Apple adjusted its strategy again)

This is also possible in Web browsers. Although all M scheme methods are blocked from jump to other apps, the Universal Links are common http Links, it is handled by the system directly, and cannot be blocked. This enables jump from to our app !!

Add a solution to the Project

Now, users can click a link to directly access our app. However, this is not our final goal. Our goal is to get the link from users, process by link and display the information to the user

Implementation Method in AppDelegate in the project

-(BOOL) application :( UIApplication *) application continueUserActivity :( NSUserActivity *) userActivity restorationHandler :( void (^) (NSArray *) restorationHandler {if ([userActivity. activityType isEqualToString: NSUserActivityTypeBrowsingWeb]) {NSURL * webpageURL = userActivity. webpageURL; NSString * host = webpageURL. host; if ([host isw.tostring: @ "yohunl.com"]) {// perform the processing we need} else {[[UIApplication sharedApplication] openURL: webpageURL];} return YES ;}

When userActivity is of the NSUserActivityTypeBrowsingWeb type, it means that it is included by the Universal Links, and we can add our own processing logic!

Postscript

If it doesn't work, refer

Refer to the iOS 9 Learning Series: connecting to the Universal link of iOS 9 (Universal Links) apple's official Universal Links iOS9 Universal Links list of apps that currently support Universal Links and their apple-app-site-association files for 51 applications. Check whether apple supports Universal Links website

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.