问题记录:
微信开放平台配置Universal Link,如下:

微信开发平台配置
-
后端开发人员在域名服务器的根路径下的
/.well-known/文件下添加apple-app-site-association配置文件(注意:文件名不能有后缀):
旧格式(苹果已弃用):
{
"applinks":{
"apps":[],
"details":[
{
"appID":”9JXXXXXXNQ.com.XXXX.www",
"paths":["/app/*"] //只要链接中包含/dgtest/就可以唤起app
}
]
}
}
新格式:
{
"applinks": {
"details": [
{
"appIDs": [ "9JXXXXXXNQ.com.XXXX.www"],
"components": [
{
"/": "/buy/*",
"comment": "Matches any URL with a path that starts with /buy/."
},
{
"/": "/help/website/*",
"exclude": true,
"comment": "Matches any URL with a path that starts with /help/website/ and instructs the system not to open it as a universal link."
},
{
"/": "/help/*",
"?": { "articleNumber": "????" },
"comment": "Matches any URL with a path that starts with /help/ and that has a query item with name 'articleNumber' and a value of exactly four characters."
},
{
"/": "/app/deeplink/*",
"comment": "Matches any URL with a path that starts with /app/universal_links/."
},
{
"/": "/app/*",
"comment": "Matches any URL with a path that starts with /app/."
}
]
}
]
},
"webcredentials": {
"apps": [ "9JXXXXXXNQ.com.XXXX.www ]
}
}
-
ios项目 TARGETS——Runner(或者项目名)——Signing&Capabilities 中通过点击
+ Capability新增Assocated Domains能力,并新增如下两个Domains记录;
项目配置.png
- 项目中微信SDK注册代码如下:
import 'package:fluwx_no_pay/fluwx_no_pay.dart' as fluwx;
class FTSocialShareUtil {
static initUtil() {
//kIosUniversalLinks是微信开放平台配置的Universal Link
fluwx.registerWxApi(
appId: kWechatPayAppId,
doOnIOS: true,
doOnAndroid: true,
universalLink: kIosUniversalLinks);
}
问题:
点击分享每次都会二次跳转,如下图:
试用_20240527_160249_0.GIF
原因:配置的Universal Link未生效
调整:
- ios项目配置的Domains记录必须是www+域名,
如:applinks:www.wodeyuming.com、webcredentials:www.wodeyuming.com - 配置文件apple-app-site-association使用新的格式
- 开放平台配置的
Universal Link,需要https+www+域名+路径,切须以/结尾
如:https://www.wodeyuming.com/app/
测试配置是否成功:
1) Safari输入Universal Links(包括完整路径)+随机字符串(例如: abc)
SDK Sample的Universal Links: https://help.wechat.com/sdksample/
测试输入Safari的Universal Links:https://help.wechat.com/sdksample/abc
2)下拉页面检查是否有打开app的入口提示(如下图)

safari.png
参考文档:
微信SDKiOS接入指南
