Facebook iOS SDK 3.1.1 "closeAndClearTokenInformation" method no working

I just upgraded from Facebook iOS SDK 3.0.X to 3.1.1, and rewrote some code...

As per Facebook documentation for the logout workflow (https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/#step3), I'm calling the closeAndClearTokenInformation method of the FBSession.activeSession object.

This seems to have no effect on the Facebook session state, because checking it right after the call still returns an open session.

As it stands, once my application logs in with Facebook, it doesn't logout.


As requested, here's the code I use to check the session state:

if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded && FBSession.activeSession.isOpen)
 //logged in
 //not logged in


Changed my logic a bit... Altered my original code to:

if (FBSession.activeSession.isOpen)
 //logged in
 //not logged in

Because FBSession.activeSession.state was returning FBSessionStateOpen, not FBSessionStateCreatedTokenLoaded.


Maybe this will help. https://developers.facebook.com/bugs/497294866962479?browse=search_507cb8ebc4f025673237228

I call all these methods together to make sure it is really logout. Crazy bugs.

[FBSession.activeSession closeAndClearTokenInformation];
[FBSession.activeSession close];
[FBSession setActiveSession:nil];

I know this may be late but on Android (3.0 SDK) the Session.getActiveSession() may return null if you're not in the same Context where you created it (or if the app was closed and the session didn't get somehow restored). It happens and it's handled by the SDK so there isn't much you can really do.

In those cases, calling closeAndClearTokenInformation() doesn't do much (if you take a look at the source code you will understand why). The solution to me was something along these lines (in Java):

Session session = Session.getActiveSession();
if (session != null) {
} else {
   // construct a new session (there are different ways to do this, this is how I do it because I need to pass the FACEBOOK_API_KEY programmatically).
   session = new Session.Builder(MyApp.getInstance()).setApplicationId(Constants.FACEBOOK_API_KEY).build();
   if (session != null) {//to be safe
     //beware with the case of Session vs sesssion.

This effectively leaves my session as:

{Session state:CREATED, token:{AccessToken token: permissions:[]}, appId:xxxxx}

Remember that created is not the same as Closed (or Open). From that state you can re-open the session without problems.

Hope this helps.

Need Your Help

What is the correct way to do a CSS Wrapper?

html css

I have heard a lot of my friends talk about using wrappers in CSS to center the "main" part of a website.