Facebook sdk3.1中注销功能崩溃

时间:2012-12-29 10:17:32

标签: objective-c ios cocoa-touch facebook-ios-sdk

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];
 }

在app delegate方法中,

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

因此,在closeSession方法中,我得到了EXC_BAD_ACCESS

1 个答案:

答案 0 :(得分:3)

在注销按钮上,单击删除存储在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类已在其invalidateSession函数中包含cookie删除,

[facebook logout];

中调用