1.设置分享到QQ互联的appKey和appSecret
QQ互联中创建的应用只有appID和appKey,但是友盟设置分享到QQ互联却需要appKey和appSecret,这个appSecret在QQ互联中是找不到的。正确的设置方法是:
//设置分享到QQ互联的appKey和appSecret
[[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:@"QQ互联的appID" appSecret:@"QQ互联的appKey" redirectURL:@"http://mobile.umeng.com/social"];
2.集成友盟第三方登录,提示代码错误
友盟文档中的代码:
- 向第三方平台获取授权
#import <UMSocialCore/UMSocialCore.h>
-(void)authWithPlatform:(UMSocialPlatformType)platformType{
[[UMSocialManager defaultManager] authWithPlatform:platformType completion:^(id result, NSError *error) { [self.tableView reloadData];
UMSocialAuthResponse *authresponse = result;
NSString *message = [NSString stringWithFormat:@"result: %d\n uid: %@\n accessToken: %@\n",(int)error.code,authresponse.uid,authresponse.accessToken];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:message delegate:nil
cancelButtonTitle:NSLocalizedString(@"确定", nil)
otherButtonTitles:nil];
[alert show];
}];
}
- 获取用户信息
#import <UMSocialCore/UMSocialCore.h>
- (void)getUserInfoForPlatform:(UMSocialPlatformType)platformType{
[[UMSocialManager defaultManager] getUserInfoWithPlatform:platformType completion:^(id result, NSError *error) { UMSocialUserInfoResponse *userinfo =result;
NSString *message = [NSString stringWithFormat:@"name: %@\n icon: %@\n gender: %@\n",userinfo.name,userinfo.iconurl,userinfo.gender];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UserInfo"
message:message
delegate:nil
cancelButtonTitle:NSLocalizedString(@"确定", nil)
otherButtonTitles:nil];
[alert show];
}];
}
将报错的方法替换为下面两个方法:
//授权平台
- (void)authWithPlatform:(UMSocialPlatformType)platformType
currentViewController:(id)currentViewController
completion:(UMSocialRequestCompletionHandler)completion;
//获取用户信息
- (void)getUserInfoWithPlatform:(UMSocialPlatformType)platformType
currentViewController:(id)currentViewController
completion:(UMSocialRequestCompletionHandler)completion;
3.QQ登录会出现两次授权的情况
分析:
出现两次授权页面的原因:授权登录的流程是,先获取授权信息,再获取用户信息。而QQ登录时,获取授权信息会跳转到授权界面,而获取用户信息时也会跳转到授权页面,所以才会出现两次跳转到授权页面。
解决办法:
不调用授权方法,直接获取用户信息。
4.分享,代码报错
将错误的方法替换为:
- (void)shareToPlatform:(UMSocialPlatformType)platformType
messageObject:(UMSocialMessageObject *)messageObject
currentViewController:(id)currentViewController
completion:(UMSocialRequestCompletionHandler)completion;
5.分享,失败2005
添加代码:messageObject.shareObject = shareObject;