0 x0000 background

Recently, the wechat SDK of the project has been upgraded to the latest version, which requires access to Universal Links service. Here are the details of access to Universal Links research.

0 x0001 research

Universal Links is a technology introduced in iOS 9. If your APP supports Universal Links, you can open your APP with an HTTPS link.

Jump to the official channel.

The Universal Links feature

  • Unique: Unlike custom URL schemes, Universal Links are not used by other apps. Because it uses standard HTTP/HTTPS links to go back to where we are
  • Secure: When a user downloads an APP, iOS checks the files you upload to the Web server to ensure that your site allows your APP to open the url under its name. Since only I have the right to create and upload the file to the server, the association between the website and APP is secure.
  • Flexible: Universal Links will work if the APP is not installed and will open the URL in Safari when the link is clicked.
  • Simple: URLS can serve both websites and apps.
  • Private: Other apps can communicate with the APP without knowing whether the app is installed.

0 x0002 access

Registered domain name

Domain The domain name must support HTTPS

Create and upload an apple-app-site-association file

{
    "applinks": {
        "apps": []."details": [{"appID": "teamID.bundleID"."paths": [ "*"] {},"appID": "9JA89QQLNQ.com.apple.wwdc"."paths": [ "/wwdc/news/"."/videos/wwdc/2015/*"}]}}Copy the code

Matters needing attention:

  • Apple-app-site-association files do not have suffixes and cannot exceed 128K if they are not compressed
  • Details can add multiple configurations and configure multiple apps at the same time
  • AppID is made up of teamID and bundleID, teamID is available from developer websites
    Membership

    BundleID in XCode

  • Paths specifies which paths can wake up the APP, all under the “*” domain
  • Apple-app-site-association is stored in the root directory of the server (registered domain name), or in the. Well-known subdirectory

To verify the apple – app – site – association

  • Type in your browserhttps://<domain>/apple-app-site-association 或 https://<domain>/.well-known/apple-app-site-associationAccess the file you just uploaded
  • Verify whether the uploaded files are correct through the test website provided by Apple. portal

Configure Universal Links in APP

  1. Configure ASSociated Domains in the development center and re-download the profile. This step can be skipped if Xcode is set to Automatically manage Signing.
  2. Xcode Configure ASSociated Domains. The format is applinks:<domain>. If the apple-app-site-association file belongs to multiple domain names, multiple ASSociated Domains can be configured.
  3. After the configuration is complete, the system adds the corresponding project fileentitlementsYou can view the configuration in the project file
  4. The Universal Links callback is handled in the AppDelegate, with the userActivity fetching the jump link for logical processing

    - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {    
        return YES;
    } Copy the code

test

Copy the link to the memo and click the jump to see if you can open the APP.

0x0003 Compare URL Scheme

The URL Scheme provides the services of inter-app redirect and Web redirect. An external APP can be opened through Scheme. If two APP definition schemes are the same, the APP installed first is called according to the sequence of APP installation.

Before iOS 9, we used URL Scheme to jump to the App from the outside. Apple added the prompt box limitation, which was not a good experience, and after iOS 9, Universal Link solved this problem perfectly. The user can wake up the APP directly through a common connection, and no other action is required.