【问题标题】:Facebook iOS - Error when disallowing app on SSO and then uninstalling appFacebook iOS - 在 SSO 上禁止应用程序然后卸载应用程序时出错
【发布时间】:2013-11-29 04:22:44
【问题描述】:

我开发了一个与 Facebook 集成的应用程序,我正在测试多个登录失败的场景。然后我看到了一个卡住我的人。

场景是:

  1. 用户使用他的帐户配置了 iOS 6 SSO。
  2. 然后用户打开应用程序,不要授权它。
  3. 然后用户从 iOS 中删除他的 Facebook 帐户。

结果:

应用程序卡住了,因为它正在获取未经授权的信息,我无法再更改它,因为 Facebook 帐户不再集成到 iOS。

我的问题是:

我需要知道用户是否在 iOS 上设置了他的 Facebook 凭据(设置 > Facebook)。 我怎么知道?我搜索了 Facebook 文档并没有找到。

这是我的代码:

+ (void)initFacebook:(void (^)(int))initResult
{
    NSLog(@"init: activeSession.state = %i", FBSession.activeSession.state);

    [FBSession renewSystemCredentials:^(ACAccountCredentialRenewResult result, NSError *error) {
        if (result == ACAccountCredentialRenewResultFailed) {
            //User has changed his password and must update his iOS login credentials
            NSLog(@"sync: ACAccountCredentialRenewResultFailed -- error.code = %i", error.code);

            //Display some message to user…           

            //Get rid of the token with wrong credentials
            [FBSession.activeSession closeAndClearTokenInformation];
            FBSession.activeSession = [[FBSession alloc] init];

            initResult(1);
        }
        else if (result == ACAccountCredentialRenewResultRejected) {
            //User has unauthorized my App in Settings > Facebook
            NSLog(@"sync: ACAccountCredentialRenewResultRejected -- error.code = %i", error.code);

            //Display some message to user…

            //Get rid of the token with wrong credentials            
            [FBSession.activeSession closeAndClearTokenInformation];
            FBSession.activeSession = [[FBSession alloc] init];

            initResult(2);
        }
        else if (result == ACAccountCredentialRenewResultRenewed) {
            //Everything is fine with iOS credentials
            NSLog(@"sync: ACAccountCredentialRenewResultRenewed -- error.code = %i", error.code);

            //Just to be sure that the session state is right
            if (FBSession.activeSession.state == FBSessionStateCreated ||
                FBSession.activeSession.state == FBSessionStateCreatedOpening ||
                FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {

                //Open the active session
                [FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"user_photos"]
                                                   allowLoginUI:YES
                                              completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                                  NSLog(@"opensession: activeSession.state = %i", FBSession.activeSession.state);


                                              }];
            }
        }
    }];
}

谢谢!

【问题讨论】:

    标签: ios facebook facebook-ios-sdk


    【解决方案1】:

    您的问题是您在错误的位置查找信息。 放弃查看 Facebook SDK 文档并转至 Social.framework documentation。 这些是关于系统 facebook 帐户的。

    【讨论】:

    • 谢谢!!我可以使用 [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook] 来验证 Facebook 的 SSO 是否设置在 iOS 6 上。无论如何,我再次编写了我的例程,不再需要它。现在,在我从 iOS 同步我的凭据后,如果返回状态为 ACAccountCredentialRenewResultRejected 我尝试再次打开会话,但使用 facebook SDK [FBSession openActiveSessionWithReadPermissions] 如果令牌卡住,则会刷新令牌。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 2017-02-01
    • 2012-07-11
    • 2020-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 2015-05-01
    相关资源
    最近更新 更多