一、与后台相关的配置
注意: 你的域名必须是https的!
- 1、在开发者中心里打开
Associated Domains
,并获取TeamID
和BundleID
; - 2、创建一个json文件,名字必须为
apple-app-site-association
(如下所示):
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TeamID.BundleID",
"paths": [
"*",
"/qq_conn/QQAppId/*"
]
}
]
}
}
- 3、将上面的json给到后台同学,让其把json配置到服务器的根目录下。在浏览器输入
https://你的域名/apple-app-site-association
,如果能下载到该json文件,则证明配置成功了。 - 4、服务器配置完成后,把你的域名填到微信和QQ的开放平台。
二、与Xcode相关的配置
- 1、在 Target -> Signing & Capability -> Associated Domains 里的Domains添加你的域名,如:
applinks:baidu.com
- 2、在 Target -> Info -> URL Types 里添加QQ和微信的Schemes:QQ的样式为
tencent1109833162
,微信的为wx4a32e264da3deefd
; - 3、在 AppDelegate 里实现:
// 1、注册
[WXApi registerApp:@"URL Schemes" universalLink:@"你的UL"];
[[TencentOAuth alloc] initWithAppId:appid andDelegate:[YourShare manager]];
// 回调
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *url = userActivity.webpageURL;
if (url && [TencentOAuth CanHandleUniversalLink:url]) {
[QQApiInterface handleOpenUniversallink:url delegate:[Your manager]];
return [TencentOAuth HandleUniversalLink:url];
}
return [WXApi handleOpenUniversalLink:userActivity delegate:[Your manager]];
}
return NO;
}