我的应用程序支持使用 facebook 登录,但是当我注销并再次登录时,我不会被要求提供任何凭据 - 它会立即使用 iOS6 中的本机用户名登录。我想要在原生 facebook 应用程序中类似的东西:
当点击“不是你”时,facebook 会提供新的登录屏幕。
我跟着这个教程
问题似乎在这里的某个地方:
- (void)openSession
{
NSArray *permissions=[NSArray arrayWithObjects: @"publish_stream", @"publish_actions",@"create_event", nil];
// [FBSession open]
[FBSession openActiveSessionWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceEveryone
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
{
switch (state) {
case FBSessionStateOpen: {
NSLog(@"Sesstion opened");
UIViewController *topViewController =
[self.navController topViewController];
NSLog(@"Class: %@", [[topViewController presentedViewController] class]);
if ([[topViewController presentedViewController]
isKindOfClass:[LoginViewController class]])
{
[topViewController dismissViewControllerAnimated:YES completion:nil];
}
ViewController *basic=(ViewController*)topViewController;
NSLog(@"Populating details");
[basic populateUserDetails];
}
break;
case FBSessionStateClosed:
{
NSLog(@"Session closed");
[FBSession.activeSession closeAndClearTokenInformation];
}
case FBSessionStateClosedLoginFailed:
NSLog(@"Login failed");
[self.navController popToRootViewControllerAnimated:NO];
[FBSession.activeSession closeAndClearTokenInformation];
[self showLoginView];
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}