Search Unity

Facebook Android won't stay logged in between sessions

Discussion in 'Android' started by unisip, Sep 28, 2015.

  1. unisip

    unisip

    Joined:
    Sep 15, 2010
    Posts:
    270
    Hi, I am testing the facebook SDK 7.1.0 with Unity 5 on Android.
    I don't have the facebook app installed on the Android device.

    I can log in with facebook properly, but every time I kill the app and restart it, I always get FB.IsLoggedIn = FALSE, meaning that I have to display the login dialog again (which tells me "you have already authorized this app").

    Am I missing something ? Is anyone else having this problem avec facebook SDK 7.1 on Android?
     
  2. heritagedevelopment

    heritagedevelopment

    Joined:
    Mar 30, 2015
    Posts:
    7
    Code (CSharp):
    1. public void OnInitComplete()
    2.     {
    3.         Debug.Log("OnInitComplete Called");
    4.        
    5.         Debug.Log("Is logged in? " + FB.IsLoggedIn);
    6.         if(FB.IsLoggedIn)
    7.         {
    8.            
    9.         }
    10.         else
    11.         { //TODO
    12.             StartCoroutine(CheckFbInit()); //Facebook BUG
    13.         }
    14.     }
    15.  
    16.     IEnumerator CheckFbInit()
    17.     {
    18.         yield return new WaitForSeconds(1f);
    19.  
    20.             if (FB.IsLoggedIn)
    21.             {
    22.                 //Here you should be logged in
    23.             }
    24.         }
    25.     }

    Try this out. Is a known bug for the. Is logged in turns true after the callback. Hope it helps.
     
  3. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    157
    same issue with me !
     
  4. YD_JMysior

    YD_JMysior

    Joined:
    Aug 4, 2016
    Posts:
    21
    I have the same issue on iOS with SDK 7.8 (Unity 5.3.4). I tried the solution suggested by HeritageDevelopment (delayed recheck) but that still doesn't work.
     
  5. Ted-Bigham

    Ted-Bigham

    Joined:
    Aug 20, 2012
    Posts:
    4
    I'm using SDK 7.8.0 an it works fine for me. I'm not doing any delays, everything is inside of OnInitComplete.

    Something like this....

    Code (CSharp):
    1. public void Login(Action<bool> callback)
    2. {
    3.     FB.Init(() =>
    4.     {
    5.         if (FB.IsLoggedIn)
    6.         {
    7.             FB.Mobile.RefreshCurrentAccessToken(response => {
    8.                 callback(true);
    9.             });
    10.         }
    11.         else
    12.         {
    13.             callback(false);
    14.         }
    15.     });
    16. }
    17.  
     
    CarlosZavala likes this.
  6. CarlosZavala

    CarlosZavala

    Joined:
    Jan 25, 2017
    Posts:
    1
    Problem solved for me, thanks :) (Unity 5.3.5 p7, Facebook SDK 7.9.4)
     
unityunity