No FBSession in Facebook iOS SDK 4.x

ⅰ亾dé卋堺 提交于 2019-11-30 16:36:52

问题


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.



来源:https://stackoverflow.com/questions/29282769/no-fbsession-in-facebook-ios-sdk-4-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!