我剛剛發現這個問題,同時測試我的應用程序,它真的開始煩我。所以環境是什麼樣子如下:安裝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];
}
我試圖改變我進行身份驗證,但總是遇到同樣問題的辦法...任何想法?
感謝
一個
您是否在您的權限數組中指定了'basic_info'權限? – MAB
你打賭!它的工作原理(驗證),如果FB應用程序存在,所以我相信權限是正確的 – Andy
如果您的應用程序權限爲OFF,您可以檢查Facebook下的設置 – MAB