问题记录:
微信开放平台配置Universal Link,如下:
- 后端开发人员在域名服务器的根路径下的
/.well-known/
文件下添加apple-app-site-association配置文件(注意:文件名不能有后缀):
旧格式(苹果已弃用):
{
"applinks":{
"apps":[],
"details":[
{
"appID":”9JXXXXXXNQ.com.XXXX.www",
"paths":["/app/*"] //只要链接中包含/app/就可以唤起app
}
]
}
}
新格式:
{
"applinks": {
"details": [
{
"appIDs": [ "teamID.应用BundId"],
"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/*",
"comment": "Matches any URL with a path that starts with /app/."
},
]
}
]
},
"webcredentials": {
"apps": [ "9JXXXXXXNQ.com.XXXX.www ]
}
}
1)以上文件中"apps"对应的是[ "teamID.应用BundId],
teamID在苹果开发者账号中查找,如下图:
2)/app/*
是配置的Universal Link格式。域名+/app/*
即可唤醒APP,其中*
为通配符,可以替换为任意字符
例如:域名+/app/123
、域名+/app/abac
、域名+/app/ab23
-
苹果开发者账号,找到项目对应BundleID勾选
Assocated Domains
能力
-
按如下步骤配置Xcode项目,TARGETS——Runner(或者项目名)——Signing&Capabilities 中通过点击
+ Capability
新增Assocated Domains
能力,并新增如下两个Domains记录;
-
项目中微信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);
}
问题:
点击分享每次都会二次跳转,如下图:
原因:配置的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的入口提示(如下图)
参考文档:
微信SDKiOS接入指南