我正在使用 Facebook SDK 3.1.1 在我的 iOS 应用程序中实现 FB Connect。在简单的情况下,无论是新的 FB 集成(在 iOS 上登录)还是通过 Web 视图回退到正常授权(在这两种情况下我都没有安装本机 Facebook 应用程序),这都可以正常工作。当我在 iOS 级别切换帐户时会出现问题。注销并使用不同的 FB 用户帐户登录。
要登录/授权,我执行:
[FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
如果然后每次都得到一个 FBSessionStateClosedLoginFailed ,即使我在closeAndClearTokenInformation
达到该状态时执行一个:
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
NSLog(@"Session State Changed: %u", [[FBSession activeSession] state]);
switch (state) {
case FBSessionStateOpen:
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
NSLog(@"FBSessionStateClosedLoginFailed ERROR: %@", [error description]);
[[FBSession activeSession] closeAndClearTokenInformation];
break;
default:
break;
}
但是,每次重试时我都会收到相同的状态。我的日志说以下内容:
FBSDKLog: FBSession **INVALID** transition from FBSessionStateCreated to FBSessionStateClosed
FBSDKLog: FBSession transition from FBSessionStateCreated to FBSessionStateCreatedOpening
FBSDKLog: FBSession transition from FBSessionStateCreatedOpening to FBSessionStateClosedLoginFailed Session State Changed: 257
FBSessionStateClosedLoginFailed TOKEN: (null)
FBSessionStateClosedLoginFailed ERROR: Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0xb24cc20 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason}
任何人都可以重现这个或知道问题可能出在哪里吗?