Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we logout facebook programmatically

I have facebook login in my iphone app using facebook sdk-3.1 .After login it will get in to my app and there I didnot give any logout button .so,when we click button login with facebook I will get the previous user facebook account .

Inorder to resolve this problem iam giving button logout.

how can I logout facebook programmatically on clicking button

am giving login like this

-(IBAction)Login:(id)sender
{

    appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
     appDelegate.getActionForLoginbtn=@"LoginwithFB";
       [appDelegate openSessionWithAllowLoginUI:YES];
}


-(BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI{


    NSArray *permissions=[[NSArray alloc]initWithObjects:@"email", nil];
    return[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
        [self sessionStateChanged:session state:state error:error];
    }];
}
like image 397
user2197875 Avatar asked Mar 28 '13 11:03

user2197875


People also ask

How do I logout of Facebook SDK on Android?

Logout from Facebook from custom button clicklogOut(); You should also remove First name, last name, email-id etc. details from SharedPreferences if you stored it. After Facebook you will need to integrate Google login in shortly.


1 Answers

Use this code:

if (FBSession.activeSession.isOpen)
{
    [FBSession.activeSession closeAndClearTokenInformation];
}
like image 156
Sumit Mundra Avatar answered Oct 20 '22 07:10

Sumit Mundra