2014-01-30 51 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

接通單點登錄

保存更改。