IOS Universal links (Universal link)

Source: Internet
Author: User
Tags blank page

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"  >  open App</a ;  <!--call number-->  <a  href  = "tel://13788889999" ;  Open dial </ a ;  <a  href  = "sms:1-408-555-1212" ;  Open System SMS app< Span class= "Hljs-tag" ></a ;   

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  ": [ "*" ] }] } } 

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

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. ActivitytypeIsequaltostring:nsuseractivitytypebrowsingweb]) {Nsurl*webpageurl = useractivity. Webpageurl;NSString*host = Webpageurl. Host;if([Host isequaltostring:@"Yohunl.com"]) {//Carry out the processing we need}Else{            [[uiapplicationSharedapplication]openurl:webpageurl]; }    }return YES;}

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)

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.