Harshit Trivedi
Harshit Trivedi

Reputation: 782

PhoneAuthProvider not working

Hello I am working with Firebase Authentication method of Phone Authentication but when I put that method that time PhoneAuthProvider given me error that not cannot resolve symbol:

  private void resendVerificationCode(String phoneNumber,
                                    PhoneAuthProvider.ForceResendingToken token) {
    PhoneAuthProvider.getInstance().verifyPhoneNumber(
            phoneNumber,        // Phone number to verify
            60,                 // Timeout duration
            TimeUnit.SECONDS,   // Unit of timeout
            this,               // Activity (for callback binding)
            mCallbacks,         // OnVerificationStateChangedCallbacks
            token);             // ForceResendingToken from callbacks
}

I am also

 PhoneAuthProvider.ForceResendingToken mResendToken;
 PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;

My Firebase version and also add service file:~

 compile 'com.google.firebase:firebase-auth:10.0.1'
 classpath 'com.google.gms:google-services:3.0.0'

So how can solve this problem

Upvotes: 2

Views: 5033

Answers (1)

nagabandaru
nagabandaru

Reputation: 645

You have to initialize the callbacks, May be you did, but you haven't shared the code.

PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks =new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
    @Override
    public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {

    }

    @Override
    public void onVerificationFailed(FirebaseException e) {

    }
};

Unless you are trying to resend the verification code. you no need to pass the token to this verifyPhoneNumber method.

PhoneAuthProvider.getInstance().verifyPhoneNumber(
        phoneNumber,        
        60,                 
        TimeUnit.SECONDS,   
        this,               
        mCallbacks,         
        token); // this token is not needed

Use this

PhoneAuthProvider.getInstance().verifyPhoneNumber(
        phoneNumber,        // Phone number to verify
        60,                 // Timeout duration
        TimeUnit.SECONDS,   // Unit of timeout
        this,               // Activity (for callback binding)
        mCallbacks,         // OnVerificationStateChangedCallbacks
        );

By doing this I am getting the verification code to my mobile. If need more help, Please share all the code which is used for phone verification.

Upvotes: 2

Related Questions