FB.Logout () does not work on Facebook UnitySDK

I was able to successfully log in to FB using the function FB.Login. Now I want to log out:

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

I expect the above code to print the value FB.IsLoggedInas false and ask me to enter the login and password in the following FB.Login.

In fact, the value is FB.IsLoggedIntrue, and I am not logged out: the next call FB.Logindoes not ask for a password, and I am not logged out when I open the facebook site in my browser.

I also tried using an undocumented query https://www.facebook.com/logout.php?next=[YourAppURL]&access_token=[ValidAccessToken], but that didn't affect me.

How can I register a user from facebook in my standalone unity application?

In fact, I need to log in with different usernames and passwords.

Perhaps I can somehow invalidate the access token, which will force FB to ask me again about the username and password?

Any help is greatly appreciated.

SDK Version: 5.0.1

Build Version: 140401.725cc2ecbc9002a

Unity Version 4.3.3f1 (c8ca9b6b9936)

+4
source share
3 answers

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

, . , Facebook, . Facebook .

0

FB.Logout() , , , .

-, Facebook . , , .

, , . Facebook, .

, , .

public void OnFacebookLogout()
{
    if (FB.IsLoggedIn)
    {                                                                                  
        FB.Logout (); 
        StartCoroutine ("CheckForSuccussfulLogout");
    } 
}

IEnumerator CheckForSuccussfulLogout()
{
    if (FB.IsLoggedIn) 
    {
        yield return new WaitForSeconds (0.1f);
        StartCoroutine ("CheckForSuccussfulLogout");
    } else 
    {
    // Here you have successfully logged out.
    // Do whatever you want as I do, I just enabled Login Button and Disabled
    // logout button through this method.
        EnableFacebookLoginButton ();
    }
}
0

I'm not sure if this is correct, but why not just make a while loop?

IEnumerator FBLogout (){
 FB.Logout ();
 while (FB.IsLoggedIn){
  print ("Logging Out");
  yield return null;
 }
 print ("Logout Successful");
}
Run codeHide result
0
source

Source: https://habr.com/ru/post/1537706/


All Articles