Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

iphone - Logout of Facebook in app using Facebook ios SDK

I have integrated Facebook login in my app and therfore user can login with both my app account and also Facebook and do corresponding actions.For Facebook integration I have added Facebook SDK.Now when Logout button is clicked in my app it has to clear all the credentials of Facebook Account.I have gone for :

-(IBAction)btnlogOutClicked:(id)sender
{
  [appDelegate fbDidlogout]; 
}
-(void)fbDidlogout
{
    FBSession* session = [FBSession activeSession];
    [session closeAndClearTokenInformation];
    [session close];
    [FBSession setActiveSession:nil];


}

But when I again click on button I m redirected directly to my account without going to Facebook Login page.

How can I logout of Facebook?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using new Facebook SDK login kit just write below line and thats it..

[[FBSDKLoginManager new] logOut];

If using swift, make sure to have the necessary imports

import FBSDKLoginKit

func logout() {
    FBSDKLoginManager().logOut()
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...