Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

c# - FB.Logout() not working in Facebook UnitySDK

I've managed to successfully log in FB using FB.Login function. Now I want to log out:

FB.Logout();
Debug.Log("FB IS LOGGED IN " + FB.IsLoggedIn);

I am expecting the above code to print the value of FB.IsLoggedIn as false and to ask me for a login and password on the next FB.Login.

In fact the value of FB.IsLoggedIn is true and I am not being logged out: next call to FB.Login does not ask for password and I am not being logged out when I open facebook site in my browser.

I've also tried to use the undocumented request to https://www.facebook.com/logout.php?next=[YourAppURL]&access_token=[ValidAccessToken] but it didn't make any effect for me.

How can I log the user out of facebook in my standalone unity application?

In fact what I need is to log in with different login and password.

Maybe I can invalidate the access token somehow which will cause the FB to ask me for login and password again?

Any help is much appreciated.

SDK version: 5.0.1

Build version: 140401.725cc2ecbc9002a

Unity Version 4.3.3f1 (c8ca9b6b9936)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe the FB.Logout operation is asynchronous, and the value of FB.IsLoggedIn would be true immediately after calling FB.Logout(). If you look at the documentation, it says:

You almost certainly should not use this function, which is provided primarily for completeness. Having a logout control inside a game that executes a Facebook-wide logout will violate users' expectations. Instead, allow users to control their logged-in status on Facebook itself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...