Ejemplo n.º 1
0
        private void GetUserToken()
        {
            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;
                }

                userToken = task.Result;
                this.gameObject.GetComponent <GlobalBlackboard>().SetValue("userToken", userToken);

                // Send token to your backend via HTTPS
                // ...
            });
        }
    public void GetAccessToken(bool forceRefresh, Action <FirebaseUserTokenResult> callback)
    {
        if (!forceRefresh && currentToken != null)
        {
            if (callback != null)
            {
                callback(currentToken);
            }
            return;
        }

        if (user != null)
        {
            targetBehaviour.StartCoroutine(ProcessFirebaseUserTokenTaskRoutine(user.TokenAsync(forceRefresh), callback));
        }
        else
        {
            if (callback != null)
            {
                callback(currentToken);
            }
        }
    }