English
One-click generation of iOS universal link
Universal Link is one of the new features of iOS 9 proposed by Apple on WWDC 2015. This feature is similar to a deep link, and it is convenient to directly launch your client application (the phone has the App installed) by opening an HTTPS link. Compared with the URLSheme used in the past, this new feature can provide an excellent user experience when realizing the seamless link of web-app. Please read [Apple Official Documentation](https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW1 before use ).
Due to the security upgrade of Apple’s iOS 13 system version, WeChat SDK version 1.8.6 requires the support of Universal Links jumps for legality verification and improved security. For more details, please refer to WeChat official instructions
Vernacular: In the past, your APP opened other APPs through URLScheme, and later Apple proposed to use Https links to Start, the corresponding app (installed) on the mobile phone is more convenient for seamless connection with web-app. WeChat responded to this proposal. Therefore, whether the APP you develop is WeChat login, WeChat payment, or WeChat sharing, etc., everything will jump to WeChat and then jump back, you need to provide this link. Otherwise, if your application opens WeChat, WeChat will not be able to open your application.
If you do not configure a universal link, using the new version of HX to submit cloud packaging will fail, prompting the following error message:
Error code = -5000
Error message:
Error: not set parameter 'UniversalLinks' @'oauth-weixin'
Configuring Universal Links the traditional way requires:
There are many details that need to be paid attention to, and it is difficult and cumbersome to debug, which has troubled a large number of developers.
Now through HBuilderX (from version 3.1.9) cloud packaging, it supports automatic generation of apple-app-site-association files, and automatically hosts them to: "free" cloud service space with CDN, ssl and other services uniCloud's front-end webpage Hosting, automatically complete the relevant configuration in manifest.json. Replaced by automation technology, the 4 steps (2-5) of the traditional way as shown above are distressing; only the following three steps are needed to directly get the universal link.
After enabling the Associated Domains service, you need to regenerate the profile file, which is used when submitting to the cloud for packaging
HBuilderX (starting from version 3.2.0) has added the setting of general link of QQ Internet and Sina Weibo open platform. Taking the WeChat module as an example, QQ and Weibo are similar.
Open the manifest.json file of the project, in the "iOS Platform Universal Links (Universal Links)" under the WeChat Login (WeChat Sharing, WeChat Payment) in the "(App) SDK Configuration" item,
Open WeChat Open Platform, and find the application that has been applied under "Mobile Application" on the "Management Center" page (if you have not applied for an application, please click "Create Mobile Application" to create a new one) application), click "View" to open the application details page.
Open QQOpen Platform, find the application that has been applied under "Mobile Application" on the "Management Center" page (if you have not applied for an application, please click "Create Mobile Application" Create a new application), click "View" to open the application details page.
https://static-fa42aa5f-xxxxxxx-xxxxxxxx.bspapp.com/qq_conn/ 11111233333/
Only need to fill in https://static-fa42aa5f-xxxxxxx-xxxxxxxx.bspapp.com/
, for details, please check [QQ filling and verification universallinks](https://wiki.connect .qq.com/%E5%A1%AB%E5%86%99%E5%8F%8A%E6%A0%A1%E9%AA%8Cuniversallinks)Open Weibo Open Platform, find the applied application under "My Applications", and click "View" to open the application details page. Click Modify after the "Application Information" column, and configure the universal link of the application in the "Universal Links" item under "iOS Application", as shown in the following figure: ![](https://img-cdn-aliyun.dcloud. net.cn/client/ulink/weibo.jpeg)
So far, the whole process of configuring the universal link has been completed, and it will take effect after cloud packaging.
The amount of cloud server resources consumed by hosting universal links is very small, and the file is less than 0.5kb. Only your iOS app will be requested by the Internet when installing, logging in, sharing, and paying (and the device will cache the file content of the universal link , there will be no further network requests within the validity period of the cache). The free quota for the front-end web page hosting of Alibaba Cloud Official Edition-Developer Edition (free edition) is: 1GB/month; the service space for ordinary projects, if only the "universal link" is hosted, the free edition is also sufficient.
The public beta version of Alibaba Cloud is about to go offline. Users who need to migrate the universal link file to the new official version service space can refer to the following steps:
uniCloud Alibaba Cloud official version - paid version, supports "one-click migration" (coming soon) and steps 3 and 4 can be omitted
Unbind the binding relationship between the domain name and the old service space
Open the old service space in uniCloud web console -> front-end web page hosting -> parameter configuration -> domain name information configure website domain name -> click delete
Bind the domain name to the new service space
Open a new service space in uniCloud web console -> front-end web page hosting -> parameter configuration -> domain name information configuration website domain name -> add domain name (CNAME after adding The value will not appear immediately, it takes a while to click the refresh button in the upper right corner until it appears) -> resolve the domain name
Designate the service space to generate the universal link
Click the manifest.json of the project in HBuilderX -> App module configuration OAuth (login authentication) -> WeChat login (the same applies to other modules), click Auto Generate -> select "Newly opened service space" -> Next -> Next -> Custom Domain Name -> Done
Automatic generation and deployment
Just submit the cloud package directly. Note: Submitting cloud packaging is just to trigger: "generate new common files and automatically deploy to new service space", and the user's client does not need to be updated.
You can use the plus.runtime.launcher of the 5+ API to determine the source of the application launch. If the value is "uniLink", it means that the application is launched through a universal link. At this time, the startup parameters can be obtained through plus.runtime.arguments of the 5+ API. When the universal link is activated, the complete universal link address will be returned. Example: The default real machine running base in HBuilderX is a universal link for HBuilderX registration: https://demo.dcloud.net.cn/ulink/
If you are packaging offline locally or for some reason you need to use the traditional way: privatize the deployment server to host the apple-app-site-association file and create a universal link. You can still configure manifest.json manually. Details: https://ask.dcloud.net.cn/article/36393#unilink
The requested file was not found on this server.
it `s just normal. A universal link does not require a valid path, in other words, the directory pointed to by this link is allowed to be empty. The principle is that when accessing this link, the iPhone detects that the current domain name is the domain name corresponding to the universal link, reads the apple-app-site-association under the domain name server, and then verifies and resolves the app to be opened according to the path name behind the domain name Package name and wake up the corresponding app.
你可以将通用链接输入到iphone自带Safari浏览器中,下拉即可看到通用链接对应到应用名称和一个打开按钮,点击按钮即可直接在浏览器打开对应的APP。详情:点此查看演示视频
3.使用微信登录、分享、支付等功能时,用户非首次调起微信,仍然出现二次跳转app
微信SDK要求通用链接apple-app-site-association文件中 path不能带query参数,且末尾必须添加通配符*号。如下:
{
"applinks": {
"apps": [],
"details": [
{
"appID":"8ARUHGUQNH.com.AppSample",
"paths": [ "/AppSample/*"]
}
]
}
}