Cannot implicitly convert type 'System.Threading.Tasks.Task (firebase)

48 views Asked by At

error CS0029: Cannot implicitly convert type 'System.Threading.Tasks.Task<Firebase.Auth.AuthResult>' to 'Firebase.Auth.FirebaseUser'

public void OnClickSignIn()

{


Copy
FirebaseAuth auth = FirebaseAuth.DefaultInstance;

Debug.Log("Clicked SignIn");

string emailText = emailSignin.GetComponent<TMP_InputField>().text;

string passwordText = passwordSignin.GetComponent<TMP_InputField>().text;

auth.SignInWithEmailAndPasswordAsync(emailText,

    passwordText).ContinueWithOnMainThread(task =>

{

    if (task.IsCanceled)

    {

        Debug.Log("SignIn Canceled");

        Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");

        return;

    }

    if (task.IsFaulted)

    {

        Debug.Log("SignIn Failed");

        Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception);

        signinFailNotification.OpenNotification();

        return;

    }

    FirebaseUser newUser = task;

    if (newUser != null)

    {

        signinSuccessNotification.OpenNotification();

        Debug.LogFormat("User signed in successfully: {0} ({1})",

            newUser.DisplayName, newUser.UserId);

    }

});
}

public void OnClickSignUp()

{


Copy
FirebaseAuth auth = FirebaseAuth.DefaultInstance;

Debug.Log("Clicked SignUp");

string emailText = emailSignup.GetComponent<TMP_InputField>().text;

string passwordText = passwordSignup.GetComponent<TMP_InputField>().text;

auth.CreateUserWithEmailAndPasswordAsync(emailText,

        passwordText)

    .ContinueWithOnMainThread(task =>

    {

        if (task.IsCanceled)

        {

            Debug.Log("Signup Canceled");

            Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");

            return;

        }

        if (task.IsFaulted)

        {

            Debug.Log("Signup Failed");

            Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);

            signupFailNotification.OpenNotification();

            return;

        }

        // Firebase user has been created.

        Debug.Log("Signup Successful");

        FirebaseUser newUser = task;

        if (newUser != null)

        {

            writeNewUser(newUser.UserId,newUser.Email);

            signupSuccessNotification.OpenNotification();

            Debug.LogFormat("Firebase user created successfully: {0} ({1})",

                newUser.DisplayName, newUser.UserId);

        }

    });
0

There are 0 answers