0

我用这个概念来登录。

-(void)LoginButtonTapped
{

    NSArray *permissions = [[NSArray alloc]initWithObjects:@"friends_email",@"user_birthday",@"user_hometown",@"user_location",@"friends_birthday",@"friends_location",@"friends_hometown", nil];

    [[delegate facebook]authorize:permissions];

    [FBSession.activeSession openWithCompletionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                    NSError *error)
     {
         NSLog(@"success");

        // [signinbutton setHidden:YES];


         }

     }];


    [permissions release];
}

但是,假设如果我在没有登录的情况下关闭登录窗口,那么它不会再次显示登录窗口。

它显示了这个错误。

*** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: an attempt was made to open an already opened or closed session'

任何想法请帮助我。

4

1 回答 1

0

您必须使用 来处理错误,FBErrorUtility当您关闭/取消 Facebook 登录时它会调用

// Handle possible errors that can occur during login

- (void)loginView:(FBLoginView *)loginView handleError:(NSError *)error {

  if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryUserCancelled) {
    NSLog(@"user cancelled login");
  }

}

在 Facebook 登录期间可能会出现许多其他错误,请参阅此处了解更多信息。

于 2014-02-10T10:31:07.477 回答