I previously used the following to clear and reset the Facebook access token
[FBSession.activeSession closeAndClearTokenInformation];
Since the update to 4.0 this no longer works. FBSession.activeSession
has changed to [FBSDKAccessToken currentAccessToken]
.
I however can't find the latest version of closeAndClearTokenInformation that works with the latest version. Any suggestions?
You can learn more about obtaining a user access token by implementing Facebook Login for Android. You can retrieve the user access token by inspecting Session. getCurrentAccessToken .
Swift 2+ Simple Solution
FBSDKLoginManager().logOut()
Swift 5+ Simple Solution
LoginManager().logOut()
FBSDKLoginManager *logMeOut = [[FBSDKLoginManager alloc] init];
[logMeOut logOut];
or
[FBSDKAccessToken setCurrentAccessToken:nil];
[FBSDKProfile setCurrentProfile:nil];
to logout
Then when you login again, make sure to set:
login.loginBehavior = FBSDKLoginBehaviorWeb;
Like so:
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
login.loginBehavior = FBSDKLoginBehaviorWeb;
[login logInWithReadPermissions:@[@"user_friends"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
etc...
}];
I found some info in the docs saying FBSDKLoginBehaviorWeb can be used for "kiosk" apps; which I guess are apps designed to have more than one person log into them routinely.
One thing to note, this login method creates a modal UIWebView which is set up for portrait mode. I'm not sure if its possible to change this yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With