Search Unity

Firebase authentication issue

Discussion in 'Scripting' started by redeev, Oct 17, 2019.

  1. redeev

    redeev

    Joined:
    Mar 15, 2015
    Posts:
    17
    Hi, i have an issue with the authentication in firebase. I'm actually using unity 2019.2 and the firebase sdk 6.6.0. Here the code i use for authentication

    Code (CSharp):
    1.  
    2. public void Login(string username, string password, Action callback)
    3.     {
    4.         auth.SignInWithEmailAndPasswordAsync(username, password).ContinueWith(task =>
    5.         {
    6.             if (task.IsCanceled)
    7.             {
    8.                 InfoPanel.main.ShowError(1);
    9.                 return;
    10.             }
    11.             if (task.IsFaulted)
    12.             {  
    13.                 InfoPanel.main.ShowMessage(3);
    14.                 return;
    15.             }
    16.  
    17.             if (auth.CurrentUser.IsEmailVerified)
    18.             {
    19.                 callback?.Invoke();
    20.             }
    21.             else
    22.             {
    23.                 InfoPanel.main.ShowError(2);
    24.             }
    25.         }, TaskScheduler.FromCurrentSynchronizationContext());
    26.     }
    27.  
    28. private void AuthStateChanged(object sender, EventArgs eventArgs)
    29.    {
    30.        if (auth.CurrentUser != CurrentUser)
    31.        {
    32.            bool signedIn = CurrentUser != auth.CurrentUser && auth.CurrentUser != null;
    33.            if (!signedIn && CurrentUser != null)
    34.            {              
    35.                LoadScene(StringRepository.LOGIN_SCENE);
    36.            }
    37.            CurrentUser = auth.CurrentUser;
    38.            if (signedIn)
    39.            {  
    40.                userRef = database.GetReference(USERS).Child(CurrentUser.UserId);        
    41.                LoadScene(StringRepository.MENU_SCENE, true);
    42.            }
    43.        }
    44.    }
    45.  
    The problem is that on Android i have a long delay(~1min) before the scene starts loading. Do you have any idea on how to solve this issue? Thanks
     
    Last edited: Oct 17, 2019
  2. kamalsalem

    kamalsalem

    Joined:
    Jul 25, 2022
    Posts:
    1
    I came here looking for a resolution for the delay problem although I'm not using Unity, let me know if you ever resolved this, but my app doesn't log on at all, it just sits there