I only want to get the OTP first. Then I will create an account. But I am unable to get OTP. The phone number format is also correct. Below is my code. Is there any error in it?
I think PhoneAuthProvider.getInstance().verifyPhone()
is working properly so there will no error in it.
public class second extends AppCompatActivity {
EditText phoneNumberET, OTPET;
String phoneNumber, verificationCode;
FirebaseAuth mAuth;
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBack;
public void submit(View view)
{
phoneNumber = phoneNumberET.getText().toString();
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallBack
);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
phoneNumberET = (EditText) findViewById(R.id.phoneNumberEditText);
OTPET = (EditText) findViewById(R.id.OTPEditText);
mAuth = FirebaseAuth.getInstance();
mCallBack = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {
Log.i("complete","inside");
}
@Override
public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
verificationCode = s;
}
@Override
public void onVerificationFailed(@NonNull FirebaseException e) {
}
};
}
}