关于shareSdk分享到微信不走回调方法的问题

项目中有微信支付的话

先检查当前用的shareSDK的版本

#import <ShareSDK/ShareSDK+Base.h>
NSLog(@"%@",[ShareSDK sdkVer]);

如果是3.6.0以前的按照下面的方式处理openurl
在WXDelegate - onResp方法中,判断resp是否为PayResp类型,而自行处理微信支付的结果
-(void)onResp:(BaseResp *)resp
{
//确认本次回调是属于支付回调
if ([resp isKindOfClass:[PayResp class]]) {
//对支付结果进行回调
NSLog(@"The response of wechat.");

}

}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
dispatch_async(dispatch_get_main_queue(), ^{
1009 - Mob移动开发者服务平台 2017-04-10 10:34:59
[WXApi handleOpenURL:url delegate:self];
});
return YES;

}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *,id> *)options
{
dispatch_async(dispatch_get_main_queue(), ^{
[WXApi handleOpenURL:url delegate:self];
});
return YES;

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

如果是3.6.0以后的,按照下面的写
在WXDelegate - onResp方法中,判断resp是否为PayResp类型,而自行处理微信支付的结果
-(void)onResp:(BaseResp *)resp
{
//确认本次回调是属于支付回调
if ([resp isKindOfClass:[PayResp class]]) {
//对支付结果进行回调
NSLog(@"The response of wechat.");

}

}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{

[WXApi handleOpenURL:url delegate:self];

return YES;

}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *,id> *)options
{

[WXApi handleOpenURL:url delegate:self];

return YES;

}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{

[WXApi handleOpenURL:url delegate:self];

return YES;
}
return YES;

}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *,id> *)options
{

[WXApi handleOpenURL:url delegate:self];

return YES;

}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{

[WXApi handleOpenURL:url delegate:self];

return YES;
}

因为留在分享平台之后分享平台是不会在将分享的信息返回给自己的应用的,所以没有办法知道状态,但依然会以Cancel状态回调。就算分享成功了,不点按钮直接返回应用也算是取消的.所以这就是为什么点击左上角的返回 返回app走的是分享的取消毁掉方法

关于shareSdk分享到微信不走回调方法的问题

上一篇:时间算法 转换 (类似微信朋友圈时间显示)


下一篇:完美解决微信下拉上拉