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];
}
謝謝.....它工作正常 –