简体   繁体   中英

No FBSession in Facebook iOS SDK 4.x

There is no more class FBSession in new Facebook iOS SDK v4.x. How can I find out whether user is logged in or not now? Thanks in advance.

Vincent是对的,检查[FBSDKAccessToken currentAccessToken]以确定用户是否已登录。

To check if the user logged in and if so, navigate to another view:

if ([FBSDKAccessToken currentAccessToken]) {
    // User is logged in
    [self performSelector:@selector(accessGrantedNavigation)
               withObject:nil afterDelay:0.0];
}

-(void)accessGrantedNavigation{
    [self performSegueWithIdentifier: @"segueLoginFB" sender: self];
}

To log out: (although it doesn't allow to change FB user. I think it is because Safari already takes care of that session and remains the same user.)

FBSDKLoginManager *manager = [[FBSDKLoginManager alloc] init];
    [manager logOut];

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM