Logout from Facebook programmatically iOS Logout from Facebook programmatically iOS ios ios

Logout from Facebook programmatically iOS


You have two methods to logout.First, as suggested by Inder Kumar Rathore

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

Second is by setting the currentAccessToken to nil

[FBSDKAccessToken setCurrentAccessToken:nil];

@cookiemonsta hope second method works for you.


FBSDKLoginManager is your need, it has logOut method but you might have to use your custom login

e.g.

FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];[loginManager logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {  if (error) {    // Process error  } else if (result.isCancelled) {    // Handle cancellations  } else {    // If you ask for multiple permissions at once, you    // should check if specific permissions missing    if ([result.grantedPermissions containsObject:@"email"]) {      // Do work    }  }}];//then logout[loginManager logOut];


Swift version:

FBSDKLoginManager().logOut()

You can use FBSDKLoginManager even if you logged in with FBSDKLoginButton.