Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logout from Facebook programmatically iOS

I am trying to logout from Facebook programmatically without using FBSDKLoginButton i had search how could I do i found this answer Can we logout facebook programatically but the problem is the FBSession is deprecated in new iOS FBSDK version

my question is Is there any way to clear the fb session in the new iOS FBSDK version? if there any way to logout from Facebook programmatically? or how could I call the logout action from FBSDKLoginButton

Thanking in advance :)

like image 921
Ahd Radwan Avatar asked Apr 14 '15 09:04

Ahd Radwan


People also ask

How do you log out of Facebook on the app?

Log out on the Facebook mobile app On your smartphone, it's also pretty simple to log out. Tap the icon of three parallel lines. Scroll down to the bottom and tap "Log Out." You'll then be prompted to confirm that you wish you log out.

How do I log out of Facebook on an iPad?

Open the Facebook app. Tap. . Scroll to the bottom and tap Log Out.


2 Answers

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.

like image 92
mars Avatar answered Sep 28 '22 02:09

mars


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]; 
like image 37
Inder Kumar Rathore Avatar answered Sep 28 '22 04:09

Inder Kumar Rathore