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];
}];
}
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.
Use this code:
if (FBSession.activeSession.isOpen)
{
[FBSession.activeSession closeAndClearTokenInformation];
}
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