3

I'm currently working on some lightweight code to correctly wrap usage of the Facebook Unity SDK for some client applications, and I've run into a minor problem, wherein the Facebook Unity SDK docs suggest that I shouldn't be doing what I am. Basically I want to know if what I'm doing is right.

  • To preface - the documentation for FB.Logout suggests that a client app should never really need to call it, as it will log the user out of facebook globally, in contradiction of their expectations. (See https://developers.facebook.com/docs/unity/reference/current/FB.Logout)
  • In my code when I receive an error from facebook which could mean the token has been invalidated, I ping off a simple request which should always succeed if the user's token is still valid. If this fails, I invoke FB.Logout, because without doing so, calling FB.Login again will simply fail - the user's token will remain the same, and the Login call will succeed.
  • Behaviourally everything behaves as I would want - calling FB.Logout just clears the local state and lets me go back to my 'initialised but not logged in' situation.

Basically, I want to know if this is expected behaviour, and whether, contrary to the documentation, this is the correct case for calling FB.Logout.

Cheers, Jeremy

1 Answers1

0

FB.Logout will log you out of Facebook and your app on the web.

On mobile, it will sign out from your app.

This is by design, and your implementation is correct.

On Web, this method will log the user out of both your site and Facebook. On iOS and Android, it will log the user out of your Application.

On all the platforms it will also invalidate any access token that you have for the user that was issued before the logout.

cf. https://developers.facebook.com/docs/unity/reference/current/FB.Logout/

Sergio Porres
  • 57
  • 1
  • 10