我刚刚使用 SDK iOS 3.1 启动了一个新应用程序,我注意到现在读写权限是分开的。
我正在寻找一种简单的方法来发布到用户墙,但我对授权机制有点困惑
如果我可以在 openActiveSessionWithReadPermissions 的 CompletionHandler 中获得写权限,我会收到以下错误
*** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: It is not valid to reauthorize while a previous reauthorize call has not yet completed.'
completionHandler 听起来动作已经完成,所以我不明白这段代码有什么问题。
有什么建议么 ?
-(void)askWritePerms
{
NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil];
[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
}];
}
- (IBAction)publishFB:(id)sender
{
NSArray *permissions = [NSArray arrayWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self askWritePerms];
}