新版微信分享 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都有了,实际不是的,提交代码时才发现。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
里配置
- (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
网友评论