gpt4 book ai didi

iphone - 在 Facebook 中注销

转载 作者:行者123 更新时间:2023-11-29 11:12:38 25 4
gpt4 key购买 nike

在我的应用程序中,我正在使用 Facebook。已将 FB 与我的应用程序集成。登录也正确发生。但是,当我尝试注销时,它在 fbDidLogout 中显示注销成功,但是当我们尝试再次登录时,它只显示登录页面并使用之前输入的用户名和密码进行登录。

如何正确退出。

任何人都可以提供帮助或建议

这是我的代码

这是登录注销按钮操作

- (IBAction)LoginOrLogout 
{
// If the user is not connected (logged in) then connect. Otherwise logout.
if (!isConnected)
{

// Set the permissions.
// Without specifying permissions the access to Facebook is imposibble.
permissions = [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", nil] retain];

// Set the Facebook object we declared. We’ll use the declared object from the application
// delegate.
facebook = [[Facebook alloc] initWithAppId:@"329082513817407" andDelegate:self];



[btnPublish setHidden:NO];
[messageTextField setHidden:NO];

[facebook authorize:permissions];

// Change the lblUser label's message.
[lblUser setText:@"Please wait..."];

isConnected = YES;
[self setLoginButtonImage];
}
else
{
[facebook logout:self];
[messageTextField setHidden:YES];

[lblUser setText:@"Tap on the Login to connect to Facebook"];
isConnected = NO;
[self setLoginButtonImage];
}
}

这些是其他方法

-(void)fbDidLogin
{
// Save the access token key info.
[self saveAccessTokenKeyInfo];

// Get the user's info.
[facebook requestWithGraphPath:@"me" andDelegate:self];
}

-(void)fbDidNotLogin:(BOOL)cancelled
{
UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"Tonify" message:@"Login cancelled." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[al show];
[self LoginOrLogout];
}

-(void)fbDidLogout
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"defaults fbDidLogout ........%@",defaults);
if ([defaults objectForKey:@"FBAccessTokenKey"])
{
[defaults removeObjectForKey:@"FBAccessTokenKey"];
[defaults removeObjectForKey:@"FBExpirationDateKey"];
[defaults synchronize];
}
NSLog(@"defaults fbDidLogout ........%@",defaults);
NSLog(@"logout success!");

// Keep this for testing purposes.
NSLog(@"Logged out Succes");

// Hide the publish button.
[btnPublish setHidden:YES];
}

最佳答案

使用这个方法:

-(void)fbDidLogout
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"defaults fbDidLogout ........%@",defaults);
if ([defaults objectForKey:@"FBAccessTokenKey"])
{
[defaults removeObjectForKey:@"FBAccessTokenKey"];
[defaults removeObjectForKey:@"FBExpirationDateKey"];
[defaults synchronize];
}

// Hide the publish button.
[btnPublish setHidden:YES];

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

关于iphone - 在 Facebook 中注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10870766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com