简体   繁体   English

Facebook iOS SDK注销

[英]Facebook iOS SDK Logout

I'm using the official and updated Facebook iOS SDK . 我正在使用官方和更新的Facebook iOS SDK
We're developing an application on an iPad that is used inside a physical store using an in-house distribution profile. 我们正在iPad上开发一个应用程序,该应用程序使用内部分发配置文件在实体店中使用。 Where customers can login to their Facebook account on an iPad that's publicly available to improve their shopping experience. 客户可以在公开的iPad上登录他们的Facebook帐户,以改善他们的购物体验。

The problem I came across is that when a user logs into their Facebook account, the next user (customer) will still be logged in with the previous users' credentials ( You have already authorized xxx, Press "Okay" to continue ). 我遇到的问题是,当用户登录他们的Facebook帐户时,下一个用户(客户)仍将使用之前用户的凭据登录( You have already authorized xxx, Press "Okay" to continue )。 Ofcourse this is not okay. 当然这不行。

Is there a way to actually logout (sign off, clear credentials, or what ever) the previous (or current) user so the next user can fill in its own username and password. 有没有办法实际注销(注销,清除凭据或什么)前一个(或当前)用户,以便下一个用户可以填写自己的用户名和密码。

Unfortunately [[FBSession activeSession] closeAndClearTokenInformation] doesn't quite do the trick. 不幸的是[[FBSession activeSession] closeAndClearTokenInformation]并不是很有效。

This is a part of the code so far: 到目前为止,这是代码的一部分:

 // .... 
 [[FBSession activeSession] closeAndClearTokenInformation];
 [FBSession.activeSession openWithCompletionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                         NSError *error) {
      // More code ...

  }];
// ...

PS. PS。 The cookie 'workaround' doesn't work for me (obviously) cookie'workaround'对我不起作用 (显然)

From your context, I'm assuming your device(s) does not have the Facebook app installed nor do you expect to use iOS 6 system authentication which would leave the default login behavior to use Safari. 从您的上下文来看,我假设您的设备没有安装Facebook应用程序,您也不希望使用iOS 6系统身份验证,这会使默认登录行为使用Safari。 If you were to clear the Safari cookies, that should work but for a smoother experience in your scenario you should use the FBSession openWithBehavior:completionHandler: method and specify a behavior of FBSessionLoginBehaviorForcingWebview so that it uses the inline webview dialog for authentication. 如果您要清除Safari cookie,这应该有效,但为了在您的场景中获得更流畅的体验,您应该使用FBSession openWithBehavior:completionHandler:方法并指定FBSessionLoginBehaviorForcingWebview的行为,以便它使用内联webview对话框进行身份验证。

See the SwitchUserSample in the Facebook iOS SDK for an example since that sample demonstrates an app that can toggle between multiple accounts. 请参阅Facebook iOS SDK中的SwitchUserSample作为示例,因为该示例演示了可以在多个帐户之间切换的应用程序。

Try with this code. 尝试使用此代码。 I think it will help you. 我认为它会对你有所帮助。

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logOut];

If you are using facebook sdk 4.1.0 just call bellow method 如果您使用的是facebook sdk 4.1.0,请调用bellow方法

if ([FBSDKAccessToken currentAccessToken]) {
     [FBSDKAccessToken setCurrentAccessToken:nil];
     [FBSDKProfile setCurrentProfile:nil]; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM