问题描述:

The Facebook SDK for iOS come with some sample applications. E.g. FriendPickerSample and SessionLoginSample. In both when I try to login it will remember my previous facebook users. But I don't want that because I want to use it with another facebook user. How do I clear the info Facebook has cached so that login will act the same as the very first time I tried to login on this device with this particular app?

Does facebook cache all its information in the app bundled? And what info does it store and in what files?

网友答案:

You need to remove all the keys stored by facebook once user logs out.

- (void)fbDidLogout
{
  NSLog(@"Logged out of facebook");
  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];
       }
   }
}
网友答案:
[[FBSession activeSession] close];

[[FBSession activeSession] closeAndClearTokenInformation];
相关阅读:
Top