Facebook iOS sdk登录注销问题

问题描述:

我们在iOS facebook登录注销问题上遇到了麻烦。当我使用我的应用程序登录Facebook时,它将通过登录和取消按钮提示用户权限。但这个屏幕只在第一次出现。即一旦我们使用safari或应用程序登录,即使我们从Facebook注销,应用程序提示用户权限的屏幕也只显示确定按钮。它不允许以其他用户身份登录。为什么每次启动应用程序时都不会显示带有登录和取消按钮的屏幕?我尝试删除cookie并删除NSUserDefaults但没有运气。

We have got sruck in the iOS facebook login logout issue. When I login to facebook using my application it will prompt for user permission with 'login' and 'cancel' button. But this screen appears only on the very first time. ie Once we logged in using safari or the app and even if we logged out from facebook , application the screen prompting for user permission displays only an 'ok' button. It doesnt allow to sign in as a different user. Why the screen with 'login' and 'cancel' button not displaying each time the application launches? I tried by deleting cookies and removing NSUserDefaults but no luck.

问题是在注销后,我无法以另一个用户身份登录facebook。它仍然显示为同一个用户。

The problem is after logout, I am unable to login to the facebook as another user. It still shows as the same user.

我在sdk中调用以下注销功能

I am calling the below logout function in sdk

(void)logout:(id<FBSessionDelegate>)delegate {

  self.sessionDelegate = delegate;
 [_accessToken release];
 _accessToken = nil;
 [_expirationDate release];
 _expirationDate = nil;

 NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
 NSArray* facebookCookies = [cookies cookiesForURL:
 [NSURL URLWithString:@"http://login.facebook.com"]];
 for (NSHTTPCookie* cookie in facebookCookies) {
   [cookies deleteCookie:cookie];
 }

if ([self.sessionDelegate respondsToSelector:@selector(fbDidLogout)]) {
  [_sessionDelegate fbDidLogout];
}
}

同样在fbDidLogout委托函数中我删除了所有NSUserDefaults对象

Also in fbDidLogout delegate function I removed all NSUserDefaults objects

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]) {
    [defaults removeObjectForKey:@"FBAccessTokenKey"];
    [defaults removeObjectForKey:@"FBExpirationDateKey"];
    [defaults synchronize];
}

regrds
Shihab

regrds Shihab

FBSession openWithBehavior:completionHandler:可以使用..

FBSession openWithBehavior:completionHandler: can be used..

FBSession *fbSession = [[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:@"email",@"publish_actions",@"publish_stream", nil]];
 [fbSession openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session,FBSessionState state, NSError *error){
    [FBSession setActiveSession:fbSession]; // Retain the Active Session.        
}];

对于退出,Ellen S的Ans适用于iOS。

For Logging out, Ans by Ellen S.. worked fine for iOS .