1
在我的应用程序中使用Facebook。我的应用程序集成了FB。 登录也正确发生。但是当我尝试注销时,它显示注销成功fbDidLogout但是当我们尝试再次登录时意味着它只是显示登录页面并使用先前输入的用户名和密码进行记录。在Facebook上注销
我们如何正确注销。
任何一个可以帮助或建议
这里是我的代码
这是登录注销按钮操作
- (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];
}
谢谢.....它工作正常 –