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
。
答案 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];