在iOS App遷移主體后洞焙,iOS native 代碼中唯一的改動就是更新了development team ID橘荠,從XXX1
改為了XXX2
,用新的cert和profile打包之后,微信登錄功能正常短纵,但是拉起微信小程序功能異常,只能看到跳轉(zhuǎn)到微信進行connecting闰蛔,然后就回到了app痕钢,沒有再次進入微信彈窗小程序。
通過WXApi startLogByLevel和自檢函數(shù)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自檢函數(shù)
[WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
NSLog(@"%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
}];
WXULCheckStep值說明:
step = WXULCheckStepParams: 參數(shù)檢查
step = WXULCheckStepSystemVersion: 當(dāng)前系統(tǒng)版本檢查
step = WXULCheckStepWechatVersion: 微信客戶端版本檢查
step = WXULCheckStepSDKInnerOperation: 微信SDK內(nèi)部操作檢查
step = WXULCheckStepLaunchWechat: App拉起微信檢查
step = WXULCheckStepBackToCurrentApp: 由微信返回當(dāng)前App檢查
step = WXULCheckStepFinal: 最終檢查
發(fā)現(xiàn)App拉起微信檢查成功任连,由微信返回當(dāng)前App檢查沒有打印任何信息,所以定位到時universal link失效后例诀,
- 檢查微信開放平臺Universal Links是否配置正確
- 檢查iOS代碼中Associate Domains配置是否正確
- 在真機的safari中打開微信開放平臺中配置的Universal Links,是否會顯示打開app的提示
當(dāng)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
進行訪問,查看其返回的配置扔罪,發(fā)現(xiàn)在更新主體后沒有更新apple-app-site-association
的返回內(nèi)容秉沼。
// 原配置
{
"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
后,發(fā)現(xiàn)還是存在之前的問題矿酵。
經(jīng)過多番查閱資料發(fā)現(xiàn)唬复,Apple CDN會對apple-app-site-association
進行緩存,在緩存過期之前全肮,是不會再到my.domain.com
下去拉取新的配置敞咧。
- 通過
https://app-site-association.cdn-apple.com/a/v1/my.domain.com
可以查看當(dāng)前app獲取到的值,并查看cache的時長和失效時間
- 等到cache失效后再次驗證,問題就解決了