directory

1. Why configure Universal Links

2.Universal Links configuration steps and verification

3. Universal Links configuration problem of wechat QQ

4. Frequently asked Questions and solutions

Universal Links

Why configure Universal Links

1.Universal Links Can be configured to wake up the APP directly by specifying the domain name path. Compared to the previous URL Scheme jump is too powerful, interested in Google to understand the detailed reasons here do not make too much explanation.

2. After 2021, third-party platforms such as QQ and wechat will carry out universal Link verification for third-party logins related to sharing. Otherwise, functions of third-party platforms cannot be used normally.

Universal Links configuration steps and verification

1. Create a JSON file named apple-app-site-association, which contains the following fixed format:

{
"applinks": {
"apps": []."details": [{"appID": "TeamID.com.demon.lan"."paths": ["*"]]}Copy the code

⚠️ Precautions:

  • The file name must be apple-app-site-association, without json suffix, without JSON suffix, without JSON suffix. Important things to say three times.

  • The format for appids in apple-app-site-Association is teamID.BundleID. TeamID and BundleID can be found on developer websites under Identifiers. (BundleID is also available in Xcode)

For example, my teamID is XXXXXXXXXXX and my bundleId is com.mytest.app. BundleID in reverse, app.mytest.com is the example domain name, which is probably what your projects are called.)

  • Paths configuration essentially limits which paths can and cannot wake up your app.

The above example is “paths” : (” “), only one has said the entire website can use, not recommended to write, so beginning of bloggers is such a configuration, a serious bug, a link to pay for the H5, click go originally H5 pay page, the results because I’m such a configuration, as long as the links contained domain directly into APP, Users can’t pay!

So we need to add some paths: for example, now our project has a function to record an event into the system calendar, which puts a specified link such as: HTTPS: / / app.mytest.com/SystemCalendar/ click directly into my APP, so I need as follows the path configuration is ok, (note: in order to compatible with the need to add fields, I added behind * to specify a certain part of the site) “paths” : [“/SystemCalendar/”] if you want to add other paths, you can use a comma to separate them. The following is an example of apple’s official documentation for paths. Note that the configured paths are case-sensitive: [ “/wwdc/news/”, “NOT /videos/wwdc/2010/”, “/videos/wwdc/201?/*”]

2. Configuration of Xcode project:

Enable Associated Domains in your Capablities, as shown below:

Be sure to fill in the format of Applinks: Domain name

3. Server configuration:

Upload the apple-app-site-association file to the server. This requires back-end development. Put the file in the root directory of the server or in the. Well-known directory.

At that time, the screenshot given to me by the backend student is as follows. Here, I still use the sample ID of the article to show it:

Make sure that the HTTPS: //app.mytest.com/apple-app-site-association this link can open the APP in Safari. It must be in this format, with no. Json suffix and no other path in the middle. App.mytest.com is your server domain name.

4. Verify that the Universal Links configuration is successful

If Universal Links has been configured, apple will send a request to the Apple-app-site-Association file on your server when the user installs your app for the first time.

After requesting the apple-app-site-Association file successfully, the user can wake up the app using Universal Links. We’d better delete the app and reinstall it to make sure Apple asks for it.

The following test methods can be referred to:

1. Directly to the HTTPS: / / app.mytest.com/SystemCalendar copied to open Safari, remember the drop-down below see will not be APP jump bar, like this is a success

2. For quick verification, enter HTTPS in the memo: //app.mytest.com/apple-app-site-association, long press the link. If the apple-app-site-association file can be displayed normally, it indicates that the server has uploaded the file successfully.

Then long press the HTTPS: / / app.mytest.com/SystemCalendar, appear “open” in the XXXX, XXXX for your project name) configuration is successful

3. Use Apple’s verification website (sometimes inaccessible) to verify whether the file can be requested by Apple. If the application is not online, the following message may be displayed when you use the verification website:

A message is displayed indicating that the apple-app-site-association file is correctly configured.

If a 404 error code is displayed, the apple-app-site-association file fails to be uploaded or HTTPS is used: // the yourdomain.com/apple-app-site-association path cannot be accessed, so you need to check the network and the backend students.

Tips: The server must support HTTPS and TLS1.2 or above, but this hole will be filled in after Apple makes HTTPS mandatory. There are still a lot of free certificates that are used by children’s servers, or certificates that are not trusted by Apple, which then make it impossible to download apple-app-site-Association. List of HTTPS root certificates supported by Apple

Apple-app-site-association file name must not be written wrong, use Charles capture package display, only the first time to install the app will request apple-app-site-association file, Therefore, the apple-app-site-Association file may fail to be obtained due to network fluctuation during the test. In this case, uninstall several times, install using 4G.

There is also a website for verifying various configurations, which needs to be thrown into an IPA package.

5. Jump into the APP through Universal Links to obtain the URL:

OC code:

-(BOOL)application:(UIApplication*)application continueUserActivity:(NSUserActivity*)userActivity restorationHandler:(void(^) (NSArray*_Nullable))restorationHandler{

NSLog(@"userActivity : %@",userActivity.webpageURL.description);

returnYES;

}
Copy the code

Swift code:

func application(_application:UIApplication.continue userActivity:NSUserActivity.restorationHandler:@escaping([UIUserActivityRestoring]?) - >Void) ->Bool{

   NSLog("userActivity :\(userActivity.webpageURL.description)")

        return true

   }
Copy the code

Implement the above method in the AppDelegate and execute it when you wake up the app with Universal Links.

Iii. Universal Links configuration of wechat QQ

  • The configuration of the QQ

Log in QQ Interconnection official website, go to application management -> Find application (need to be approved) -> View

Fill in the relevant information as prompted, and finally generate the following Universal Links :app.mytest.com/qq_conn/123… 12345678 (note that this is not the APPID of the project, it is generated by QQ);

In the project, the QQSDK needs to be configured with the Universal Links, and the initialization will let you upload it

Then add the path qq_conn/12345678 to apple-app-site-association as follows

“paths”: [ “/SystemCalendar/“, “/qq_conn/12345678/“]

/qq_conn/12345678/*

Relevant QQ configuration can refer to QQUniversallinks configuration

  • Wechat configuration

Similar to the above QQ, personally feel much simpler than QQ, log in the background to configure a Universal Links, if there is a specified path, add the specified path as above, you can also directly fill in the domain name, initialization within the project and pass in.

4. Common problems and solutions

1: Why should associate Domains be configured in appids and projects?

In order to tell the system that my app supports Universal Links when the app is launched, it is convenient for the system to download apple-app-site-Association files according to the domain domain configured in the project.

2: The apple-app-site-association file is configured with a bunch of what is used?

Block the link as WebKit loads and jump to the target app’s configuration file.

According to the above written match, how can not open it??

A. HTTPS must be supported and must meet the requirements of an APPLE-certified HTTPS certificate.

B. The configuration file is faulty. The path configured in the apple-app-site-association file is not the same as the common link used for the test.

C. The domain name configured in Xcode is incorrectly written.

6. Why do some phones work and others don’t??

As mentioned above, due to network fluctuations, some users may not be able to download apple-app-site-Association files at the first installation. This can only guide the user to delete and reload or modify the Associated Domains configuration during iteration to tell the system to re-download the apple-app-site-association file.

7. What if the server changes the domain name??

The blogger did a small test. When new Domains are added to Associated Domains, apple will send a request to the newly added Domains when the app starts again and the package is found (no need to delete and reinstall). Request the apple-app-site-association file under the new Domain. In other words, if the Associated Domains change, the system will know, so that the old domain can be deleted and the new domain can be added during iteration. Wildcards can also be used to configure Domains, for example, applinks:*. Mywebsite.com

8. You can open memos and Safari apps, but you can’t share them in other apps.

Not cross domain, such as: share the link of the WeChat is www.mydomain.com/share.html,… www.mydomain.com/index.html. … Do not use the same domain name as the web page that invokes common links. That is, if the domain name of the common link is www.mydomain.com, the domain name of the common link cannot be www.mydomain.com.

Just give it a thumbs up and go