我已经使用 Facebook SDK 注销了 facebook。但是,再次转到同一帐户,它在表格视图中显示值两次(例如:Prem Kumar。此名称在单元格中显示两次)。
//用于登录
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView
{
// first get the buttons set for login mode
NSLog(@"success");
[HUD showWhileExecuting:@selector(LoadingProcess) onTarget:self withObject:nil animated:YES];
if (FBSession.activeSession.isOpen)
{
NSLog(@"TOKEN : %@",[[FBSession activeSession]accessTokenData]);
FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,picture,birthday,location"];
[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSArray *data = [result objectForKey:@"data"];
for (FBGraphObject<FBGraphUser> *friend in data)
{
[delegate.friendsListArray addObject:friend];
NSLog(@"%@:%@:%@", [friend name],[friend birthday],[friend id]);
}
if ([delegate.friendsListArray count]!=0)
{
NSUserDefaults * standardDefaults=[NSUserDefaults standardUserDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];
[standardDefaults setObject:delegate.friendsListArray forKey:@"FriendsListArray"];
[standardDefaults setBool:YES forKey:@"logged_in"];
[standardDefaults synchronize];
NSLog(@"%@",[standardDefaults objectForKey:@"FriendsListArray"]);
BirthdayList * birthdaylist=[[BirthdayList alloc]init];
[self.navigationController pushViewController:birthdaylist animated:NO];
[birthdaylist release];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Friends not found" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}];
}
}
在设置.m
-(void)LogoutTapped
{
NSLog(@"Logged out of facebook");
NSUserDefaults * standardDefaults=[NSUserDefaults standardUserDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];
NSArray *keys = [[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]allKeys]copy];
for(NSString *key in keys)
{
[standardDefaults removeObjectForKey:key];
[standardDefaults removeObjectForKey:@"FriendsListArray"];
[standardDefaults removeObjectForKey:@"logged_in"];
[standardDefaults synchronize];
NSLog(@"Key Name: %@", key);
}
[delegate.friendsListArray removeAllObjects];
[keys release];
NSLog(@"%@",[standardDefaults objectForKey:@"FriendsListArray"]);
NSLog(@"%@",[standardDefaults objectForKey:@"logged_in"]);
NSUserDefaults * userinfodefaults=[NSUserDefaults standardUserDefaults];
NSArray *userkeys = [[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]allKeys]copy];
for(NSString *userkey in userkeys)
{
[userinfodefaults removeObjectForKey:userkey];
[userinfodefaults removeObjectForKey:@"userinfo"];
[userinfodefaults removeObjectForKey:@"userbool"];
NSLog(@"key1 Name: %@",userkey);
}
[delegate.UserListArray removeAllObjects];
[delegate.Setmonthdataarray removeAllObjects];
[delegate.SetMonthlistarray removeAllObjects];
[userinfodefaults synchronize];
[userkeys release];
FBSession *session=[FBSession activeSession];
[session closeAndClearTokenInformation];
[session close];
[[FBSession activeSession] closeAndClearTokenInformation];
[[FBSession activeSession] close];
[FBSession setActiveSession:nil];
[delegate facebook].accessToken=nil;
[delegate facebook].expirationDate=nil;
NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray* facebookCookies = [cookies cookiesForURL:
[NSURL URLWithString:@"http://login.facebook.com"]];
for (NSHTTPCookie* cookie in facebookCookies)
{
[cookies deleteCookie:cookie];
}
for (NSHTTPCookie *_cookie in cookies.cookies)
{
NSRange domainRange = [[_cookie domain] rangeOfString:@"facebook"];
if(domainRange.length > 0){
[cookies deleteCookie:_cookie];
}
}
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Logout" message:@"Logout Successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
MainList * mainlist=[[MainList alloc]initWithNibName:@"MainList" bundle:nil];
[self.navigationController pushViewController:mainlist animated:NO];
[mainlist release];
}
还有一个疑问。
要登录 facebook,我使用了 Facebook SDK。
要注销 facebook,我使用了 Facebook 库。(Facebook.m,Facebook.h)
有什么问题吗?
任何想法请帮助我。