博客時間:2020年 4月8日
軟件:XCODE 11.3.1
1.后臺文件配置 :
1.1 用命令建立一個文件,名字:apple-app-site-association。不要后綴名。
名字不能錯:
名字不能錯:
名字不能錯:
touch apple-app-site-association
打開編譯器,在這個文件中寫入如下內容
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TeamID.BundleID",
"paths": ["/hehe/*"]
},
]
}
}
TeamID:你的開發者賬號的的TeamID :
image-20200408110513538
BundleID:你App 的BundleID :
image-20200408110715947
/hehe/:是你的訪問路徑。比如說你的服務器的域名是 www.baidu.com .那么你訪問的路徑為 www.baidu.com/hehe/ 不要忘記后面的通配符。
1.2 把這個apple-app-site-association 文件放在服務器的根目錄里。測試一下,是不是能訪問。
注意:服務器要支持https
2 開發賬號設置
2.1 開發賬號bunldId 設置,選中 Associated Domains
image-20200408113447317
2.2 重新編輯profile:
找到對應的profie 編輯有一下,重新下載,打開
image-20200408113813763
重新編輯profile,下載以后編輯;
image-20200408114149132
3.工程設置
3.1 增加 Associated Domains
image-20200408114606496
3.2 配置鏈接:
前綴:是固定的applinks :
域名:是你服務器的域名,必須是https,
注意:Domains 配置的時候不能帶https 。
如,正確為:applinks:www.baidu.com ?
錯誤寫為:applinks:https://www.baidu.com ?
image
3.3 配置工程LSApplicationQueriesSchemes;
在工程的info.pist 加入如下三個鍵值
image-20200408115118201
3.4 配置工程 ”-ObjC -all_load“
image
4.增加代碼
4.1 AppDelegate.m 增加代碼
a.WX_LINKURL 是通用鏈接Univerasl Link:你的服務器域名+你配置的hehe
b.WXAPPID 是微信注冊的AppID
比如:你的服務器域名為 https://www.baidu.com 在1.1 步驟,你的配置paths 為 /hehe/* 你的Univerasl Link為: https://www.baidu.com/hehe/
#import "AppDelegate.h"
[WXApi registerApp:WXAPPID universalLink:WX_LINKURL];
4.2 AppDelegate.m 回調方法
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{
NSLog(@"userActivity : %@",userActivity.webpageURL.description);
return [WXApi handleOpenUniversalLink:userActivity delegate:self];
}
5.微信Univerasl Link配置
就拿4.1 舉例,Univerasl Link需要配置成為https://www.baidu.com/hehe/,既可以。
這個不需要審核,立刻生效。
6.測試代碼
DLog(@"微信當前SDK版本:%@",[WXApi getApiVersion]);
//調用自檢函數
[WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
DLog(@"%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
DLog(@"微信你好?");
}];
結果:
0, 1, check passed,
1, 1, check passed,
2, 1, check passed,
3, 1, check passed,
4, 1, check passed,
5, 1, Universal Link check passed. The application is launched by WeChat via Universal Link,
6, 1, All Check Passed!,
7.實際分享 出現了如下所示的問題:
image.png
--------------------------------------------------------------------------------------------------------待續---------------------------------------
目前正在微信平臺提問題,反題。等待客服回答。
經過了快一周的等待,客服終于有了反饋,大致意思是我們雖然用了微信1.8.7的SDK,但是沒有用戶分享數據的記錄,或者說是分享的記錄不多,所以還是顯示未驗證的應用。下面是我們的回復記錄。
image