Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook iOS SDK Logout

I'm using the official and updated Facebook iOS SDK.
We're developing an application on an iPad that is used inside a physical store using an in-house distribution profile. Where customers can login to their Facebook account on an iPad that's publicly available to improve their shopping experience.

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). 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.

This is a part of the code so far:

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

  }];
// ...

PS. The cookie 'workaround' doesn't work for me (obviously)

like image 287
basvk Avatar asked Nov 19 '12 16:11

basvk


1 Answers

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. 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.

See the SwitchUserSample in the Facebook iOS SDK for an example since that sample demonstrates an app that can toggle between multiple accounts.

like image 193
Chris Pan Avatar answered Oct 02 '22 06:10

Chris Pan