我刚刚发现这个问题,同时测试我的应用程序,它真的开始烦我。所以环境是什么样子如下:安装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