[英]Facebook iOS SDK request permission publish_actions, but user need to input password again
Facebook iOS SDK 3.8 was used in my project, and now I upgrade it to 3.22. 我的项目中使用了Facebook iOS SDK 3.8,现在我将其升级到3.22。
A weird thing occurred during requesting "publish_actions" permission, which is the user need to input her account&password again. 在请求“ publish_actions”权限期间发生了一件奇怪的事情,这是用户需要再次输入她的帐户和密码。 While in the previous version the part "login again" will just be skipped.
在以前的版本中,“再次登录”部分将被跳过。 I want to know if the logic in Facebook SDK changes, or I have to change the session handling process.
我想知道Facebook SDK中的逻辑是否更改,或者我必须更改会话处理过程。 Any ideas on this problem?
关于这个问题有什么想法吗?
The way I used to request the "publish_actions" permission is: 我用来请求“ 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) {
}
And I also tried 我也尝试过
[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/
}
}];
This behavior is the default set by Facebook. 此行为是Facebook的默认设置。 The document https://developers.facebook.com/docs/facebook-login/ios/v2.2 says that:
文件https://developers.facebook.com/docs/facebook-login/ios/v2.2指出:
The Disadvantage of WebView is:
WebView的缺点是:
People have to fill in their login credentials every time they go through the login flow.
人们每次进行登录流程时都必须填写其登录凭据。
In the FBSession.m file, I change the code in method 在FBSession.m文件中,我更改了方法中的代码
- (void)retryableAuthorizeWithPermissions:(NSArray *)permissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
integratedAuth:(BOOL)tryIntegratedAuth
FBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth
fallback:(BOOL)tryFallback
isReauthorize:(BOOL)isReauthorize
canFetchAppSettings:(BOOL)canFetchAppSettings
And do not delete cookie when asking for another permission, replace 并且在请求其他权限时不要删除cookie,而是
// To avoid surprises, delete any cookies we currently have.
[FBUtility deleteFacebookCookies];
with 同
// To avoid surprises, delete any cookies we currently have.
if(!isReauthorize){
[FBUtility deleteFacebookCookies];
}
I agree that it is not a good idea to modify the SDK source, while I should make some balance between the consistence of user experience and the code style. 我同意修改SDK源代码不是一个好主意,但我应该在用户体验的一致性和代码样式之间取得一些平衡。 ;(
(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.