Firebase Auth Task stop in auth.SignInAnonymouslyAsync

251 views
Skip to first unread message

Dominic Wagas

unread,
Jul 1, 2019, 5:09:51 PM7/1/19
to Firebase Google Group
here is my sample code first it starts login then check first if there is existing account in device, now in the code you see in line 34 the log did not show up so below of my code wont work during start.. 
and but when I restart the app.. the code will work.. any fix on that?? cause I really need to get the  FirebaseUID in line 33 during the first run on the app
I attached a file to see the image log


  1. Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
  2.     {
  3.       var dependencyStatus = task.Result;
  4.       if (dependencyStatus == Firebase.DependencyStatus.Available)
  5.       {
  6.         auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
  7.         user = auth.CurrentUser;
  8.         if (user != null)
  9.         {
  10.           Debug.Log("Already Existing FirebaseAccount " + user.UserId);
  11.           FirebaseUID = user.UserId;
  12.           DisplayName = user.DisplayName;
  13.           gameObject.GetComponent<FirebaseDatabaseScript>().OnStartFirebaseDatabase();
  14.         }
  15.         else
  16.         {
  17.           Debug.Log("OnLoginAnon ");
  18.           // OnLoginAnon();
  19.           // auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
  20.           auth.SignInAnonymouslyAsync().ContinueWith(autask =>
  21.           {
  22.             if (autask.IsCanceled)
  23.             {
  24.               Debug.LogError("SignInAnonymouslyAsync was canceled.");
  25.               return;
  26.             }
  27.             if (autask.IsFaulted)
  28.             {
  29.               Debug.LogError("SignInAnonymouslyAsync encountered an error: " + autask.Exception);
  30.               return;
  31.             }
  32.             Debug.Log("SignInAnonymouslyAsync " + autask.Result.UserId);
  33.             FirebaseUID = autask.Result.UserId;
  34.             Debug.LogFormat("User signed in successfully: {{0} {1}}", autask.Result.DisplayName, autask.Result.UserId); // did not show on the log mean it stops
  35.             if (string.IsNullOrEmpty(DisplayName))
  36.             {
  37.               OnUpdateUserName(DisplayName);
  38.             }
  39.             else
  40.             {

  41.             }

  42.           });
  43.         }
  44.       }
  45.       else
  46.       {
  47.         UnityEngine.Debug.LogError(System.String.Format(
  48.           "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
  49.         // Firebase Unity SDK is not safe to use here.
  50.       }
  51.     });

Untitled10.png

Alex Ames

unread,
Jul 2, 2019, 5:34:26 PM7/2/19
to fireba...@googlegroups.com
Hi Dominic, 

That does sound odd. It sounds like maybe an exception is being thrown, but then it's getting silently consumed by unity. 

Can you try putting a try/catch block around lines 32-34 and see if there's an error being thrown? If there's an exception being thrown there that we can catch we can get more information on what the issue might be. 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/454a6785-8d51-43d8-bd85-216409375f3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

thomas ecolasse

unread,
Jul 15, 2019, 10:05:38 AM7/15/19
to Firebase Google Group
I've got the exactly same problem, I'll use your tips Alex tonight, I'll let you know about it.

Dominic Wagas

unread,
Jul 15, 2019, 11:16:04 PM7/15/19
to Firebase Google Group
Same it wont passed in line 32-34
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

Dominic Wagas

unread,
Jul 15, 2019, 11:16:04 PM7/15/19
to Firebase Google Group
Hi Alex this what I got from full log

Untitled25.png


Untitled26.png




On Wednesday, July 3, 2019 at 5:34:26 AM UTC+8, Alex Ames wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

Alex Ames

unread,
Jul 17, 2019, 2:42:55 PM7/17/19
to fireba...@googlegroups.com
Like I said before, it looks like it's throwing an exception, but it's hard to tell why it might be doing that. Clearly you can get the UserId without issue. The only thing different that the next log statement is doing is also trying to print the DisplayName. 

Can you wrap your log statement in a try block, and print out the exception so we can see what's going wrong?

For example, something like this:

try {
    Debug.LogFormat("User signed in successfully: {{0} {1}}", autask.Result.DisplayName, autask.Result.UserId);
} catch (Exception ex) {
    Debug.LogFormat("Something went wrong: %s", ex);
}


To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Shawn Kuang

unread,
Jul 26, 2019, 11:43:10 PM7/26/19
to Firebase Google Group
Hi Dominic,

Does the suggestion from Alex help your issue?
Shawn
Reply all
Reply to author
Forward
0 new messages