In the process of developing iOS applications, it is inevitable to use wechat login and sharing. When the configuration is incorrect, it will often prompt:
XXXX failed because the application universal Link verification failed. ProcedureCopy the code
So what is Universal Link
Universal Links is one of the new features apple introduced in iOS9 at WWDC 2015. This feature is similar to deep Links and makes it easy to launch your client App directly by opening an Https link. Compared to the URL Scheme used in the past, this new feature provides an excellent user experience when implementing seamless links in the Web-app.
What exactly is this scenario? For example, when your user browses a webpage of your company in wechat, the user’s mobile phone also has your company’s App installed at the same time. Universal Links enables users to directly open your app when opening a detail page and reach the corresponding content page in the app, so as to implement the operations they want (such as viewing a certain news, viewing the details of a certain product, etc.).
Specific adaptation steps are as follows:
- To determine the application
Bundle id
That’s the picture
- Apply for developer certificate –
bundle id
Set ‘Associated Domains’ as above
‘open state’
3. Record the Team ID
- write
apple-app-site-association
A file cannot have a name extension. The file format is as follows:
ABCD1234 is the Team ID in Step 3 and com.aaa.app is the Bundle ID in Step 1.
The following examples are in JSON format, the first is an example, which can be directly extended if the project supports multiple
{
"applinks": {
"apps": [],
"details": [
{
"appID": "ABCD4321.com.bbb.app",
"paths": [ "*" ]
}
]
}
}
Copy the code
-
Send the apple-app-site-association file prepared in Step 4 to the background and put it in the root directory of the project (you need to register your own domain name and support Https).
-
Back in the project: Add Associated Domains and set
- Apply for binding wechat to wechat open platform
Add and modify application information Universal Links after filling in https://your_domain/, And make sure that the apple-app-site-association file can be accurately downloaded via TTPS ://your_domain/apple-app-site-association/
- The project integrates wechat SDK login and sharing functions
Use pod ‘WechatOpenSDK’ or download and drag it directly into the project
-
URL Types in the info.plist file add a type URL Schemes AppID for wechat open platform
-
code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... // Register NSString * UNIVERSAL_LINK = @"https://your_domain/"; [WXApi registerApp:kwxAppId universalLink:UNIVERSAL_LINK]; . return YES; }Copy the code
The rest is the normal logic. If you don’t pull up wechat normally, please check it again according to the steps. If it is normal, it will be done in a short time
End