如何统一获得用户参考firebase?

时间:2018-10-22 18:34:54

标签: firebase unity3d firebase-authentication

我尝试获取firebase用户,但总是用户返回空引用,我需要为用户进行另一个初始化?有什么主意吗?

代码是:

public class sendPush : Manager<sendPush>     
{
  Firebase.Auth.FirebaseAuth auth;
  Firebase.Auth.FirebaseUser user;

protected override void Awake()
{
    auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
    Debug.Log(user);
}

public string IdDevice()
{
    user = auth.CurrentUser;
    Debug.Log(user);

    user.TokenAsync(true).ContinueWith(task =>
    {
        if (task.IsCanceled)
        {
            Debug.LogError("TokenAsync was canceled.");
            return;
        }

        if (task.IsFaulted)
        {
            Debug.LogError("TokenAsync encountered an error: " + task.Exception);
            return;
        }

        string idToken = task.Result;
    });

    return user.ToString();
}

}

也许我需要一个类或一些东西来填充用户,但是我不知道如何...任何想法?

0 个答案:

没有答案