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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Vincent is right, check [FBSDKAccessToken currentAccessToken] to determine if the user is logged in.
回答2:
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.