2014-01-30 41 views
4

我刚刚发现这个问题,同时测试我的应用程序,它真的开始烦我。所以环境是什么样子如下:安装Facebook的登录 - 如果用户帐户存在(和应用程序未安装)登录失败

  • 没有Facebook应用
  • 用户登录到iOS系统帐户(在设置 - > Facebook的)

当我的应用程序试图验证用户第一次提供了这堵墙的文字:(我试图清除它一点点)

2014-01-30 15:20:31.439 Unifeed[2140:70b] Session is <FBSession: 0xb74f9e0, state:   
FBSessionStateClosedLoginFailed, 
loginHandler: 0x0, appID: *************, urlSchemeSuffix: ,  
tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0xb73bd90>, 
expirationDate: (null),  
refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)> 

2014-01-30 15:20:31.440 Unifeed[2140:70b] Session closed 
2014-01-30 15:20:31.440 Unifeed[2140:70b] User logged out 

2014-01-30 15:20:31.441 Unifeed[2140:70b] Error occured Error Domain=com.facebook.sdk Code=2  
"The operation couldn’t be completed. (com.facebook.sdk error 2.)" 
UserInfo=******** 
{com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:SystemLoginCancelled,  
com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts Code=7 "The operation 
couldn’t be completed. (com.apple.accounts error 7.)", 
com.facebook.sdk:ErrorSessionKey=<FBSession: 0xb74f9e0, state: FBSessionStateClosedLoginFailed, 
loginHandler: 0x0, appID: ************, urlSchemeSuffix: 
, tokenCachingStrategy:<FBSessionTokenCachingStrategy: 
0xb73bd90>, expirationDate: (null), refreshDate: (null), 
attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>} 

2014-01-30 15:20:31.441 Unifeed[2140:70b] User cancelled login 
2014-01-30 15:20:31.445 Unifeed[2140:70b] User logged out 

我知道那稍显混乱,但我采取的是其犯错了因为它认为用户取消了登录过程。事情是,我从来没有看到小弹出问我,如果我想登录或接受权限....所以我添加了Facebook应用程序的电话,它的工作...以及这很好,但如果我有一个用户不是应用程序,但他们有FB登录在手机上....任何人有任何想法?

我的验证码如下:(差不多就只有一点点从FB网站修改)

- (void) facebookSessionChange { 
// If the session state is any of the two "open" states when the button is clicked 
if (FBSession.activeSession.state == FBSessionStateOpen 
    || FBSession.activeSession.state == FBSessionStateOpenTokenExtended) { 

    // Close the session and remove the access token from the cache 
    // The session state handler (in the app delegate) will be called automatically 
    [FBSession.activeSession closeAndClearTokenInformation]; 

    // If the session state is not any of the two "open" states when the button is clicked 
} else { 
    // Open a session showing the user the login UI 
    [FBSession openActiveSessionWithReadPermissions:permissions 
             allowLoginUI:YES 
            completionHandler: 
    ^(FBSession *session, FBSessionState state, NSError *error) { 
     [self sessionStateChanged:session state:state error:error]; 
    }]; 
} 
} 

- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error 
{ 

NSLog(@"Session is %@", session); 
// If the session was opened successfully 
if (!error && state == FBSessionStateOpen){ 
    NSLog(@"Session opened"); 
    // Show the user the logged-in UI 
    [self userLoggedIn]; 
    return; 
} 
if (state == FBSessionStateClosed || state == FBSessionStateClosedLoginFailed){ 
    // If the session is closed 
    NSLog(@"Session closed"); 
    // Show the user the logged-out UI 
    [self userLoggedOut]; 
} 

// Handle errors 
if (error){ 
    NSLog(@"Error occured %@", error); 
    if ([FBErrorUtility shouldNotifyUserForError:error] == YES){ 
     NSLog(@"Error occured %@", error); 
    } else { 

     // If the user cancelled login, do nothing 
     if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryUserCancelled) { 
      NSLog(@"User cancelled login"); 

      // Handle session closures that happen outside of the app 
     } else if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryAuthenticationReopenSession){ 
      NSLog(@"Session is no longer valid"); 

     } else { 
      //Get more error information from the error 
      NSDictionary *errorInformation = [[[error.userInfo objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"] objectForKey:@"body"] objectForKey:@"error"]; 
      NSLog(@"Error occured : %@", [errorInformation objectForKey:@"message"]); 
     } 
    } 
    // Clear this token 
    [FBSession.activeSession closeAndClearTokenInformation]; 
    // Show the user the logged-out UI 
    [self userLoggedOut]; 
} 
} 

// Show the user the logged-out UI 
- (void)userLoggedOut 
{ 
    NSLog(@"User logged out"); 
} 

// Show the user the logged-in UI 
- (void)userLoggedIn 
{ 
    NSLog(@"User Logged in"); 
    [_delegate doneLogginginToFb]; 
} 

我试图改变我进行身份验证,但总是遇到同样问题的办法...任何想法?

感谢

一个

+0

您是否在您的权限数组中指定了'basic_info'权限? – MAB

+0

你打赌!它的工作原理(验证),如果FB应用程序存在,所以我相信权限是正确的 – Andy

+0

如果您的应用程序权限为OFF,您可以检查Facebook下的设置 – MAB

回答

4

我觉得我没在这里重现你的错误,你的申请被拒绝访问Facebook帐户设置(出于某种原因,也许你点击了“不允许” .. 。) 在用户拒绝访问或关闭Facebook设置中的开关后,应用程序不会再次询问权限,每次尝试连接时都会失败,并显示FBErrorCategoryUserCancelled状态。

要解决此问题,请转至设置>常规>重置,然后重置位置&隐私。 之后运行您的应用程序,您应该能够看到提示请求权限。

+0

没有工作 - 我是否应该从我的FB设置中删除应用程序,然后重置我的设备(模拟器)?如果在“真实”情况下发生这种情况,那么该怎么办? – Andy

+0

当您休息位置和隐私时,您的应用程序不应该在FB设置中 – MAB

+0

好吧,现在我从我的FB中删除应用程序,然后按照您的说明重置 - 。它现在记录我登录成功登录后立即登出我引用相同的错误,但现在它也说错误400,用户没有验证应用程序(这是有道理的casue我从来没有机会)它也说会话是不再有效.... – Andy

2

我只是有同样的问题,它让我疯狂。我通过更新Facebook SDK到最新版本来解决问题。

不知道这是否是你的问题,但我希望这有助于某人。

+0

认真,这是如何远程接受他们的做法? –

4

转到Facebook开发>您的应用程序>设置>基本

点击+添加平台

输入您包ID

接通单点登录

保存更改。