I have implemented Firebase authentication in my android application. I want to implement Authentication with OTP verification but when I try to authenticate with OTP it won’t send OTP. Instead of OTP I get an error:
[SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 BILLING_NOT_ENABLED
I’m new to android development and I set minSdk
and targetSdk
. also add SHA 1 key and SHA 256 in my Firebase console.
This is my code of SendOTPActivity.java
:
public void onClick(View view) {
if (inputMobile.getText().toString().trim().isEmpty()) {
Toast.makeText(SendOTPActivity.this, "Enter Mobile", Toast.LENGTH_SHORT).show();
return;
}
progressBar.setVisibility(View.VISIBLE);
buttonGetOTP.setVisibility(View.INVISIBLE);
PhoneAuthProvider.getInstance().verifyPhoneNumber(
PhoneAuthOptions.newBuilder(FirebaseAuth.getInstance())
.setPhoneNumber("+91" + inputMobile.getText().toString()) // Phone number to verify
.setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
.setActivity(SendOTPActivity.this) // Activity for callback binding
.setCallbacks(new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {
progressBar.setVisibility(View.GONE);
buttonGetOTP.setVisibility(View.VISIBLE);
}
@Override
public void onVerificationFailed(@NonNull FirebaseException e) {
progressBar.setVisibility(View.GONE);
buttonGetOTP.setVisibility(View.VISIBLE);
Toast.makeText(SendOTPActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
public void onCodeSent(@NonNull String verificationId, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
progressBar.setVisibility(View.GONE);
buttonGetOTP.setVisibility(View.VISIBLE);
Intent intent = new Intent(getApplicationContext(), VerifyOTPActivity.class);
intent.putExtra("mobile",inputMobile.getText().toString());
intent.putExtra("verificationId",verificationId);
startActivity(intent);
}
}).build()
);
}
I expect OTP verification on my real android device without billing account. As I’m new to android development I want to learning Firebase authentication with OTP.
Manan Ka Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.