今天不忙,随便测试下自己做的app,发现集成友盟三方登录的时候,微博登录后并绑定手机号的一个bug。
当我启动应用第一次进行授权登录并绑定手机号正常,取消绑定操作也正常。再次点击立即绑定授权页的回调信息那些uid什么的信息全部是null。没有错是null。
最后才发现错误在这里发生。
这个时候估计你把绑定的操作放在了授权成功的回调里面。此时需要一个判断
#pragma mark - 三方登陆
- (void)getUserInfoForPlatform:(UMSocialPlatformType)platformType
{
WEAKSELF
[[UMSocialManager defaultManager] getUserInfoWithPlatform:platformType currentViewController:nil completion:^(id result, NSError *error) {
NSString *message = nil;
if (error) {
message = [NSString stringWithFormat:@"Get info fail:\n%@", error];
UMSocialLogInfo(@"Get info fail with error %@",error);
}else{
if ([result isKindOfClass:[UMSocialUserInfoResponse class]]) {
UMSocialUserInfoResponse *resp = result;
// 第三方登录数据(为空表示平台未提供)
// 授权数据
NSLog(@" uid: %@", resp.uid);
NSLog(@" openid: %@", resp.openid);
NSLog(@" accessToken: %@", resp.accessToken);
NSLog(@" refreshToken: %@", resp.refreshToken);
NSLog(@" expiration: %@", resp.expiration);
// 用户数据
NSLog(@" name: %@", resp.name);
NSLog(@" iconurl: %@", resp.iconurl);
NSLog(@" gender: %@", resp.unionGender);
// 第三方平台SDK原始数据
NSLog(@" originalResponse: %@", resp.originalResponse);
if ([resp.uid length] > 0) {
//执行绑定操作
}
}else{
message = @"Get info fail";
}
}
}];
}
这样解决了我的bug
其实我也不是特别明白。为什么取消绑定后还会再走一下回调,并且信息被清楚了或者说在没有授权状态下信息是空的。。。呢?希望哪位大神知道的留言给我。