Jump to content
UnitySpain
Sign in to follow this  
gustavov800

Ayuda firebase y unity

Recommended Posts

Saludos, estoy trabajando con unity y firebase, creando un login algo basico con el codigo que entrega firebase pero me sale un error, si alguien me ayudar selo agradeceria.

El error sale en unity al ejecutar.

Quote

 

CreateUserWithEmailAndPasswordAsync encountered an error: System.AggregateException: Exception of type 'System.AggregateException' was thrown.
-----------------
Firebase.FirebaseException: The email address is badly formatted.

UnityEngine.Debug:LogError(Object)
AuthManager:<CreateUser>m__0(Task`1) (at Assets/scripts/AuthManager.cs:63)
System.Threading.Tasks.TaskCompletionSource`1:SetException(AggregateException)
Firebase.Internal.TaskCompletionSourceCompat`1:SetExceptionInternal(TaskCompletionSource`1, AggregateException) (at Z:/tmp/tmp.BPuGn4thFw/firebase/app/client/unity/proxy/TaskCompletionSourceCompat.cs:29)
Firebase.Internal.TaskCompletionSourceCompat`1:SetException(TaskCompletionSource`1, AggregateException) (at Z:/tmp/tmp.BPuGn4thFw/firebase/app/client/unity/proxy/TaskCompletionSourceCompat.cs:38)
Firebase.Auth.FirebaseAuth:CompleteFirebaseUserTask(Task`1, TaskCompletionSource`1) (at Z:/tmp/tmp.t8IpFzDey1/firebase/auth/client/unity/proxy/FirebaseAuth.cs:538)
Firebase.Auth.<CreateUserWithEmailAndPasswordAsync>c__AnonStoreyA:<>m__0(Task`1) (at Z:/tmp/tmp.t8IpFzDey1/firebase/auth/client/unity/proxy/FirebaseAuth.cs:525)
System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
Firebase.Auth.<GetTask>c__AnonStorey0:<>m__0() (at Z:/tmp/tmp.t8IpFzDey1/firebase/auth/client/unity/proxy/Future_User.cs:73)
Firebase.Auth.Future_User:SWIG_CompletionDispatcher(Int32) (at Z:/tmp/tmp.t8IpFzDey1/firebase/auth/client/unity/proxy/Future_User.cs:155)
Firebase.AppUtilPINVOKE:PollCallbacks()
Firebase.AppUtil:PollCallbacks() (at Z:/tmp/tmp.BPuGn4thFw/firebase/app/client/unity/proxy/AppUtil.cs:32)
Firebase.Platform.FirebaseAppUtils:PollCallbacks() (at Z:/tmp/tmp.BPuGn4thFw/firebase/app/client/unity/proxy/FirebaseAppUtils.cs:33)
Firebase.Platform.FirebaseHandler:Update() (at Z:/tmp/tmp.jXjuHREWLm/firebase/app/client/unity/src/Unity/FirebaseHandler.cs:205)
Firebase.Platform.FirebaseMonoBehaviour:Update() (at Z:/tmp/tmp.jXjuHREWLm/firebase/app/client/unity/src/Unity/FirebaseMonoBehaviour.cs:45)

 

 

Pero el codigo esta bien y es el mismo que da firebase, ya verifique con 2 cuentas de googlge y me da el mismo error.

 

Este es el codigo.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AuthManager : MonoBehaviour
{

    protected Firebase.Auth.FirebaseAuth auth;
    protected Firebase.Auth.FirebaseUser user;
    //private string displayName;

    [SerializeField] private  InputField inputFieldEmail = null;
    [SerializeField] private InputField inputfieldPassword = null;



    void Start()
    {
        InitializeFirebase();
    }





    void InitializeFirebase()
    {
        auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        auth.StateChanged += AuthStateChanged;
        AuthStateChanged(this, null);
    }
    void AuthStateChanged(object sender, System.EventArgs eventArgs)
    {
        if (auth.CurrentUser != user)
        {
            bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null;
            if (!signedIn && user != null)
            {
                Debug.Log("Signed out " + user.UserId);
            }
            user = auth.CurrentUser;
            if (signedIn)
            {
                //displayName = user.DisplayName ?? "";
                Debug.Log("Signed in " + user.UserId);
            }
        }
    }
    public void CreateUser ()
    {
        string email = inputFieldEmail.text;
        string password = inputfieldPassword.text;

        auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
                return;
            }

            // Firebase user has been created.
            Firebase.Auth.FirebaseUser newUser = task.Result;
            Debug.LogFormat("Firebase user created successfully: {0} ({1})",
                newUser.DisplayName, newUser.UserId);
        });

    }

}

 


 

 

 

Edited by pioj
Por favor, usa el <> o el "quote" para pegar código.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×
×
  • Create New...