Universal Link-Universal Link

Preface

The purpose of universal links is similar to URL Scheme. It is mainly used to wake up the App from the outside and perform certain operations (such as opening a specified page).

When using URL Scheme (wechat://path?quary) to wake up your own application from the current App, you need to add the URL Scheme of the application to the whitelist of the current App, which limits the flexibility of this method. Using Universal link can just solve this problem. The problem (https://domain name/path).

application

The link must be of https protocol and be cross-domain (different from the current domain name) when the link is opened in webView before it will be evoked as a universal link.

Store a file named apple-app-site-association in the root directory or .well-know directory. ( https://domainname/.well-know/apple-app-site-association  or https://domainname/apple-app-site-association )

m.iqiyi.com Universal Link Configuration

m.qq.com Universal Link Configuration

The content format of the apple-app-site-association file is as follows:

{
   "applinks":{
       "apps":[],
       "detail":[
           {
               "appID": "TeamID.com.app.once",
               "paths": [ "/once/deeplink/*", "/once/download/*"]
           }, {
               "appID": "TeamID.com.app.second",
               "paths": [ "/second/deeplink/*", "/second/download/*"]
           }
        ]
   }
}

1. Select the corresponding Identifier in the Apple Developer Center and enable the ASSociated Domains service.

2. In Xcode, open Target-Capabilities and set Associated Domains

3. IOS callback processing

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
    
    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
        NSURL *webUrl = userActivity.webpageURL;
        if ([webUrl.host isEqualToString:@"域名"]) {

        }  
    }
    return YES;
}

Guess you like

Origin blog.csdn.net/z119901214/article/details/89501314