Kalpesh
Kalpesh

Reputation: 5334

Crash on Logout Functionality in Facebook sdk3.1

I am using facebook sdk 3.1 & FBloginview.So i want to perform logout functionality 
from other view controller..
 Here is my code,

-(void)logout
{
    AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate];

    if (FBSession.activeSession.isOpen) 
    {
        [appdelegate closeSession];       
    }
    [appdelegate openSessionWithAllowLoginUI:NO];
 }

in app delegate method,

- (void) closeSession
{
    [FBSession.activeSession closeAndClearTokenInformation];
}

So in the closeSession method I am getting EXC_BAD_ACCESS.

Upvotes: 1

Views: 279

Answers (1)

Wolverine
Wolverine

Reputation: 4329

On logout button click remove all keys stored in userdefault for facebook

- (void)fbDidLogout
{
  NSHTTPCookie *cookie;
  NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

  for (cookie in [storage cookies])
  {
      NSString* domainName = [cookie domain];
      NSRange domainRange = [domainName rangeOfString:@"facebook"];
      if(domainRange.length > 0)
      {
          [storage deleteCookie:cookie];
      }
   }
}

OR

Facebook class already includes the cookie removal in its invalidateSession function,

which is called in [facebook logout];

Upvotes: 3

Related Questions