IOS Universal links (Universal link)

Source: Internet
Author: User
Tags blank page

The company's operations, found that a large number of recent requests/.well-known/apple-app-site-association this file, resulting in a large number of 404, but who requested it?
In fact, Apple has changed the path of the generic link's request file from iOS9.3.
From the original /apple-app-site-association to the present /.well-known/apple-app-site-association
Official website documents in Universallinks document
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.
From then on, do not need to upload to the root directory of the site, but the directory. well-known

Brief introduction

What is universal links (universal link)?
This is a feature of iOS9, and if your app supports universal links, then it's easy to launch the app via a traditional HTTP link (if your app is already installed on your iOS device, no additional judgment is required, etc.), or open a webpage ( Your app is not installed on your iOS device. It might be easier to explain, before iOS9, the need to wake up apps from a variety of browsers, Safari, UIWebView, or Wkwebview. We usually only use scheme. First, register a scheme in the app, for example

In the Web page,

<a href="kaola://www.kaola.com">打开APP</a><!-- 呼叫号码 --><a href="tel://13788889999">打开拨号</a><a href="sms:1-408-555-1212">打开系统的短信app</a>
    • 1
    • 2
    • 3
    • 4

However, there is a bad place in this way, it is necessary to determine in advance whether the system is installed to respond to the scheme of the app, this judgment, many online, such as the wake-up app from the browser or WebView, as described in the article, many pages of the judgment is problematic, often appear blank page , can not jump and so on. Even more tragic is the way in which other apps are opened by way of scheme, which is disabled in. This means that the app is not open to our app.

Universal links (Universal link): A common HTTP link, such as HTTPS://YOHUNL.COM/OPENAPP, when you support universal links, the system installed your app, then users click on the link, directly into your app, Whether you are in the middle or somewhere else!!! When you do not have the installation, you can go to your designated page (you can directly display your original H5 page, you can also jump to the download page, etc.). That is, the user does not need to know if you have installed the app, if installed, this link can be in the app (into your app, You can use the local native page to display information to the user, no installation, directly into the original H5 page, for the user, is a seamless process, very smooth!

Official Explanatory documents

Advantages of Universal links (Universal link)
    • Uniqueness : Unlike a custom scheme, because it is linked to your Web site using standard Http/https, it is not declared by other apps. In addition, custom URL scheme is not installed because it is a customized protocol Case is not directly open, and universal links itself is a http/https link, so there is better compatibility
    • Security : When your app is installed on the user's phone, iOS will go to your website to download the documentation you uploaded (this document declares which types of HTTP links your app can open). Because only you can upload files to the root of your site, So the connection between your website and your app is secure.
    • variable : Universal links also works when your app is not installed on your phone. If you like, when you don't have your app installed, the user clicks the link and displays the content of your site in Safari.
    • simple : A URL link that can act on both the website and the app
    • Private Other apps can communicate with your app without needing to know if your app is installed.
How to support universal links (Universal link) Prerequisites:

You must have a domain name, and the site needs to support HTTPS, and then have the site's upload to the root directory permissions (this permission is to upload an apple-specified file)

Support for universal links (Universal link)
    • To create a JSON-formatted named Apple-app-site-association file, note that the file must have no suffix and the filename 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 ": [ "*" ] } ] }} 
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

Description
AppID: Here the composition is Teamid.yourapp ' s bundle identifier. If the 9ja89qqlnq,abcd1234 above are Teamid, where does this value come from?
It is from the personal center of the developer account and is logged into your Developer center

COM.APPLE.WWDC is your way to be Teamid.yourapp ' s, in your Xcode project

Paths
According to the paths key set a list of the paths your app supports, only the links of these specified paths can be processed by the app, for example: If your site is www.yohunl.com , your path is written "/support/*", then when the user clicks www.yohunl.com/support/myDoucument , You will be able to enter your app, instead of Www.yohunl.com/other.
path is case-sensitive!
* number indicates any path.

    • Upload the file apple-app-site-association to your domain name corresponding to the root of the site (in fact, not necessarily the root directory, such as Ghost blog site, there is no root directory, it needs to be placed in the corresponding theme directory), this step is for Apple to https://你的域名/apple-app-site-associationxh Get the apple-app-site-association file that you uploaded.
      After uploading, you first visit to see if you can get to, with my example, Https://yohunl.com/apple-app-site-association, when you click on this link, should be to download the Apple-app-site-association file.
      To verify that the file is legitimate, Apple provides a Web page to help developers to verify that the apple-app-site-association we have written is valid, validates the URL, and enters the site for verification.

    • Some configuration in the Xcode project
      The first is to open the associated domains in the project configuration.

      Fill in the domains in which you want to support the domain name (here is not a random, is to support the universal links you need to the domain name), must be applinks: as a prefix
      For example, my fill-in is

applinks:yohunl.comapplinks:www.yohunl.com
    • 1
    • 2

Apple will fill in the domain request file from here at the right time apple-app-site-association

Note: When you open associated domains, Xcode will add the. entitlements file to your project
And if you log in to your Developer center, you can see
, these are all helpful to you to eliminate the problem.

Here, your app can already support universal links (universal link)!!!
So how to test it?

Test Universal links (Universal link) is in effect

Add a Notepad or text message to the memo in your iOS device to enter a link that the app can identify, and then click the link directly to jump to your app.
or long press, the second item in the pop-up menu that appears is "open in ' XXX '", which also represents success.

Or the URL you are going to test into a Web page in Safari, then click on the link, on the page that appears, down, you can see the "XX" app open (many tutorials, in Safari directly click, will jump to the app, but after I actually verified, is not possible, Maybe the Apple has adjusted the strategy again.)

In the Web browser, it is also possible, although blocking all the custom scheme way to jump to other apps, but universal links (universal link) because it is a normal HTTP link, directly processed by the system, can not be blocked, And that's how it went from jumping to our app!!.

How to add processing in engineering

Now the user clicks on a link, can directly into our app, however, this is not our ultimate goal, our goal is to be able to get the user to come in the link, according to the link to deal with, need to show the user information

The method of realization in Appdelegate in engineering

- (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 Isequaltostring:@ "yohunl.com"]) {//do the processing we need} else {[[uiapplication Sharedapplication]openurl:webpageurl]; }} return yes;}        
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

When Useractivity is a nsuseractivitytypebrowsingweb type, it means that it is coming in from the universal links and can add our own processing logic!

Postscript

If the encounter can not work, http://stackoverflow.com/questions/32751225/ios9-universal-links-does-not-work on the discussion of various possible problems, you can refer to the following

Reference
    1. iOS 9 Learning Series: Universal links to iOS 9 (Universal links)
    2. Apple official Universal Links
    3. IOS9 Universal Links
    4. List of files listed by foreign people that currently support the Universal Links app and its apple-app-site-association file 51 apps
    5. See if you support Universal links's Apple website URL

IOS Universal links (Universal link)

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.