简体   繁体   English

Facebook iOS SDK请求权限publish_actions,但用户需要再次输入密码

[英]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.

相关问题 如何在iOS登录期间请求Facebook publish_actions权限 - How to request Facebook publish_actions permission during login in iOS 无法验证Facebook publish_actions权限 - Trouble verifying Facebook publish_actions permission 如何从我的Swift应用程序请求Facebook publish_actions权限? - How can I request Facebook publish_actions permission wfrom my Swift app? Facebook iOS SDK:如何在请求publish_actions时处理SKIP按钮? - Facebook iOS SDK: How to handle SKIP button when requesting publish_actions? 我是否需要上载ios应用程序以进行审查,才能获得iOS游戏的publish_actions权限? - Do I need to upload my ios app for review in order to get publish_actions permission for my iOS game? openActiveSessionWithPublishPermissions / requestNewPublishPermissions publish_actions未添加权限 - openActiveSessionWithPublishPermissions / requestNewPublishPermissions publish_actions not adding permission Facebook iOS SDK强制嵌入式Webview请求发布流权限 - Facebook iOS SDK Force Embedded Webview to request publish stream permission 在Facebook SDK 3.0 iOS中阅读和发布权限 - read and publish permission in facebook sdk 3.0 iOS Facebook IOS SDK:检测用户拒绝publish_stream权限的时间 - Facebook IOS SDK: Detect when user reject the publish_stream permission 如何使用iOS SDK发布包含地图的Facebook操作? - How to publish Facebook actions that include maps using iOS SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM