我正在实现以下代码来检查应用程序中我的 Facebook 会话的状态
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen:
if (!error) {
// We have a valid session
NSLog(@"User session found");
[self reautorizarPermisos:self ];
}
break;
case FBSessionStateClosed:
NSLog(@"sesion close");
[self loginFB:self ];
break;
case FBSessionStateClosedLoginFailed:
NSLog(@"sesssion failed");
[FBSession.activeSession closeAndClearTokenInformation];
break;
default:
break;
}
[[NSNotificationCenter defaultCenter]
postNotificationName:UIDocumentStateChangedNotification
object:session];
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
此代码是从此处访问 facebook 文档
我正在调用方法如下
- (IBAction)login:(id)sender {
FBSession *sesion;
FBSessionState state;
NSError *error;
[self sessionStateChanged:sesion state:state error:error];
NSLog(@"loginnnnnnn");
}
问题是状态没有进入任何案例,显然会话既没有打开也没有关闭或失败非常感谢您的帮助