美文网首页iOS开发
微信SDK与Universal Links 的配置

微信SDK与Universal Links 的配置

作者: hypercode | 来源:发表于2020-06-15 11:26 被阅读0次

新版微信分享 SDK要求必须使用Universal Links,所以 升级了一下工程,概要如下:
pod 'WechatOpenSDK', '~> 1.8.7.1'

1.Info.plist里

<string>wechat</string>
<string>weixin</string>
<string>weixinULAPI</string>

App.entitlements 以及AppDebug.entitlements
Targets=>Signing&Capabilities=>Release及
Targets=>Signing&Capabilities=>Debug
填写不包含 paths 的域名根目录 https://********
这里有个坑,配置了一个 All 后以为Debug和Release都有了,实际不是的,提交代码时才发现。

image.png
    • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      里配置
[WXApi registerApp:AppKey universalLink:@"https://xxxxxxx"];

4.AppDelegate里添加如下代码

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return  [WXApi handleOpenURL:url delegate:self];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [WXApi handleOpenURL:url delegate:self];
}
- (BOOL)application:(UIApplication *)application
  continueUserActivity:(NSUserActivity *)userActivity
   restorationHandler:(nonnull void (^)  (NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler{
    return [WXApi handleOpenUniversalLink:userActivity
                             delegate:self];
}

可参考:
https://www.jianshu.com/p/06108091db86
https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/iOS.html

相关文章

网友评论

    本文标题:微信SDK与Universal Links 的配置

    本文链接:https://www.haomeiwen.com/subject/dadcxktx.html