Sunday, June 5, 2022
HomeGame Developmentunity - Firebase OTP credential confirm does not work with cellphone quantity

unity – Firebase OTP credential confirm does not work with cellphone quantity


I’ve 2 capabilities, the primary operate works accurately. The second, after I put the OTP and need to confirm the code from my SMS it does not work, it solely creates a consumer in my Firebase database however it will not present me the debug textual content and run the opposite codes like altering the scene.

public void SendOTP()
{
   
    supplier = PhoneAuthProvider.GetInstance(auth);
    
    supplier.VerifyPhoneNumber(countryCode.textual content + phoneNumber.textual content, phoneAuthTimeoutMs, null,
      verificationCompleted: (credential) => {
          // Auto-sms-retrieval or prompt validation has succeeded (Android solely).
          // There isn't a have to enter the verification code.
          // `credential` can be utilized as an alternative of calling GetCredential().
      },
      verificationFailed: (error) => {
          // The verification code was not despatched.
          // `error` accommodates a human readable rationalization of the issue.
      },
      codeSent: (id, token) => {
          verificationId = id;
          debug.textual content = "code despatched";
          // Verification code was efficiently despatched through SMS.
          // `id` accommodates the verification id that might want to handed in with
          // the code from the consumer when calling GetCredential().
          // `token` can be utilized if the consumer requests the code be despatched once more, to
          // tie the 2 requests collectively.
      },
      codeAutoRetrievalTimeOut: (id) => {
          // Known as when the auto-sms-retrieval has timed out, based mostly on the given
          // timeout parameter.
          // `id` accommodates the verification id of the request that timed out.
      });
}

public void VerifyOTP()
{
    
    Credential credential = supplier.GetCredential(verificationId, otp.textual content);

    auth.SignInWithCredentialAsync(credential).ContinueWith(process => {
        debug.textual content = ("Person signed in efficiently");
        if (process.IsFaulted)
        {
            debug.textual content = ("SignInWithCredentialAsync encountered an error: " +
                           process.Exception);
            return;
        }

        FirebaseUser newUser = process.Consequence;
        debug.textual content = ("Person signed in successfully22");
        // This could show the cellphone quantity.
        //debug.textual content = ("Cellphone quantity: " + newUser.PhoneNumber);
        // The cellphone quantity providerID is 'cellphone'.
       // debug.textual content = ("Cellphone supplier ID: " + newUser.ProviderId);
        SceneManager.LoadScene("Menu");
    });
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments