問題記錄:
微信開放平臺配置Universal Link,如下:
微信開發(fā)平臺配置
-
后端開發(fā)人員在域名服務(wù)器的根路徑下的
/.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);
}
問題:
點擊分享每次都會二次跳轉(zhuǎn),如下圖:
試用_20240527_160249_0.GIF
原因:配置的Universal Link未生效
調(diào)整:
- ios項目配置的Domains記錄必須是www+域名,
如:applinks:www.wodeyuming.com
、webcredentials:www.wodeyuming.com
- 配置文件apple-app-site-association使用新的格式
- 開放平臺配置的
Universal Link
,需要https+www+域名+路徑,切須以/
結(jié)尾
如: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接入指南