1

我遵循了图形 API,到目前为止一切顺利。当我尝试从 Facebook 注销时出现问题。永远不会发生注销:我使用了这种方法:

    [facebook logout];

我已经实现了委托方法:

    - (void) fbDidLogout {

NSLog(@"did logout");

// Remove saved authorization information if it exists
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]) {
    [defaults removeObjectForKey:@"FBAccessTokenKey"];
    [defaults removeObjectForKey:@"FBExpirationDateKey"];
    [defaults synchronize];
}

}

问题是用户再次运行应用程序时再次登录。我希望每次进入 Facebook 屏幕时,新用户都应该登录。然而这种方法不起作用。请帮忙

4

3 回答 3

4
- (void)logOutFB {

fbGraph.accessToken = nil;
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];
    }
}
}
于 2012-06-08T10:24:12.223 回答
1

实现以下代码

Facebook *fb; //your fbconnect object

if([fb isSessionValid])
{
    fb.accessToken = nil;
    fb.expirationDate = nil;
}
于 2012-06-08T09:18:28.193 回答
0

试试看 :

-(void)fbLogout  {  
    fbGraph.accessToken = nil;  
    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];
        }       }   [NSUserDefaults resetStandardUserDefaults];
    [[NSUserDefaults standardUserDefaults]removeObjectForKey:@"fb_accesstoken"];    fbGraph.accessToken = nil;
    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];
        }
    }  }
于 2012-06-08T09:27:56.650 回答