在iOS App迁移主体后,iOS native 代码中唯一的改动就是更新了development team ID,从XXX1
改为了XXX2
,用新的cert和profile打包之后,微信登录功能正常,但是拉起微信小程序功能异常,只能看到跳转到微信进行connecting,然后就回到了app,没有再次进入微信弹窗小程序。
通过WXApi startLogByLevel和自检函数checkUniversalLinkReady打印日志,帮助定位问题:
[WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
NSLog(@"----log: %@", log);
}];
2024-01-23 10:02:19.510409+0800 xxx[2160:510406] ----log : wxlog:send req[<WXLaunchMiniProgramReq: 0x282c508c0>], appID:wxappid, universalLink:https://my.domain.com/app/wxappid/, sdkVersion:2.0.2
2024-01-23 10:02:19.510753+0800 xxx[2160:510406] ----log : wxlog:LaunchMiniProgram todata extDic=(null)
2024-01-23 10:02:19.515957+0800 xxx[2160:510406] -canOpenURL: failed for URL: "weixinURLParamsAPI://" - error: "This app is not allowed to query for scheme weixinurlparamsapi"
2024-01-23 10:02:19.524212+0800 xxx[2160:510406] ----log : wxlog:set property list
2024-01-23 10:02:19.532727+0800 xxx[2160:510406] ----log : wxlog:Error:fail to load Keychain status:-25300, keyData null:1
2024-01-23 10:02:19.532869+0800 xxx[2160:510406] ----log : wxlog:token[(null)] is null
2024-01-23 10:02:19.652510+0800 xxx[2160:510406] ----log : wxlog:launch app with ul only success
2024-01-23 10:02:19.652624+0800 xxx[2160:510406] ----log : wxlog:launch app with universal link, ret:1
2024-01-23 10:02:19.652672+0800 xxx[2160:510406] ----log : wxlog:req:<WXLaunchMiniProgramReq: 0x282c508c0>, cid:25ad1b7ca0d3dff09535890984fe1008c1XXXX
2024-01-23 10:02:19.652704+0800 xxx[2160:510406] ---wxapi version: 2.0.2
// WXApi自检函数
[WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
NSLog(@"%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
}];
WXULCheckStep值说明:
step = WXULCheckStepParams: 参数检查
step = WXULCheckStepSystemVersion: 当前系统版本检查
step = WXULCheckStepWechatVersion: 微信客户端版本检查
step = WXULCheckStepSDKInnerOperation: 微信SDK内部操作检查
step = WXULCheckStepLaunchWechat: App拉起微信检查
step = WXULCheckStepBackToCurrentApp: 由微信返回当前App检查
step = WXULCheckStepFinal: 最终检查
发现App拉起微信检查成功,由微信返回当前App检查没有打印任何信息,所以定位到时universal link失效后,
- 检查微信开放平台Universal Links是否配置正确
- 检查iOS代码中Associate Domains配置是否正确
- 在真机的safari中打开微信开放平台中配置的Universal Links,是否会显示打开app的提示
当Universal Link在safari中打开,并无打开app的提示,怀疑是apple-app-site-association
中的配置有问题。
通过 Universal Link中的domain + apple-app-site-association
, 如https://my.domain.com/apple-app-site-association
或 https://my.domain.com/.well-known/apple-app-site-association
进行访问,查看其返回的配置,发现在更新主体后没有更新apple-app-site-association
的返回内容。
// 原配置
{
"applinks": {
"apps": [],
"details": [
{
"paths": [
"/app/wxappid/*"
],
"appID": "teamID1.bundle_id"
}
]
}
}
// 修改后的配置
{
"applinks": {
"apps": [],
"details": [
{
"paths": [
"/app/wxappid/*"
],
"appID": "teamID1.bundle_id"
} ,
{
"paths": [
"/app/wxappid/*"
],
"appID": "teamID2.bundle_id"
}
]
}
}
更新apple-app-site-association
后,发现还是存在之前的问题。
经过多番查阅资料发现,Apple CDN会对apple-app-site-association
进行缓存,在缓存过期之前,是不会再到my.domain.com
下去拉取新的配置。
- 通过
https://app-site-association.cdn-apple.com/a/v1/my.domain.com
可以查看当前app获取到的值,并查看cache的时长和失效时间
- 等到cache失效后再次验证,问题就解决了