简体   繁体   中英

Facebook logout iOS SDK

In the latest SDK of Facebook for iOS 8, the login button itself changes to logout once the user logs in successfully. I have a separate logout button in my applications. When the user is successfully logged in using my own server credentials, google+ or facebook, the app takes the user to a place where he cannot access the login page again untill he logs out. So i want to logout the user from facebook once the user presses my logout button. Can someone please guide me how to do that, in earlier SDKs it used to be the session which was used to log the user out.

[[FBSession activeSession] close]; [[FBSession activeSession] closeAndClearTokenInformation];

but this doesnt work anymore in the current SDK to logout the user. Instead the same login button has to be clicked. Is there any function or any other workarround that I can do for it ?

try this one :

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

Second option which you can try

-(void)logout{

      [FBSDKAccessToken setCurrentAccessToken:nil];
}

* Method to logout from Facebook *

-(void) logout
{
    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

    if ( [FBSDKAccessToken currentAccessToken] ){
        [login logOut];
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM