我的项目中使用了 Facebook iOS SDK 3.8,现在我将其升级到 3.22。
在请求“publish_actions”权限时发生了一件奇怪的事情,即用户需要再次输入她的帐户和密码。而在以前的版本中,“再次登录”部分将被跳过。我想知道 Facebook SDK 中的逻辑是否发生了变化,或者我必须更改会话处理过程。关于这个问题的任何想法?
我用来请求“publish_actions”权限的方式是:
[activeSession openWithBehavior: FBSessionLoginBehaviorForcingWebView
completionHandler:^(FBSession *session,
FBSessionState state, NSError *error) {
[session reauthorizeWithPermissions:@[@"publish_actions"]
isRead:NO
behavior:FBSessionLoginBehaviorForcingWebView
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
}
我也试过
[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
__block NSString *alertText;
__block NSString *alertTitle;
_reauthorizeInProgress = YES;
if (!error) {
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound){
// Permission not granted, tell the user we will not publish
alertTitle = @"Permission not granted";
alertText = @"Your action will not be published to Facebook.";
[[[UIAlertView alloc] initWithTitle:alertTitle
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil] show];
} else {
// Permission granted, publish the OG story
}
} else {
// There was an error, handle it
// See https://developers.facebook.com/docs/ios/errors/
}
}];