Facebook iOS - 在SSO上禁用应用程序然后卸载应用程序时出错

时间:2013-11-29 04:22:44

标签: ios facebook facebook-ios-sdk

我开发了一个带有Facebook集成的应用程序,我正在测试多个失败的登录方案。然后我看到一个困扰我的人。

场景是:

  1. 用户已使用其帐户配置iOS 6 SSO。
  2. 然后用户打开应用程序,不要授权。
  3. 然后用户从iOS移除他的Facebook帐户。
  4. 结果:

    应用程序因为获取未经授权的信息而陷入困境,因为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);
    
    
                                                  }];
                }
            }
        }];
    }
    

    谢谢!

1 个答案:

答案 0 :(得分:0)

您的问题是您在错误的地方寻找信息。 退出查看Facebook SDK文档并转到Social.framework documentation。 这些是关于系统的Facebook帐户。