Search code examples
androidfirebasefirebase-authentication

OTP SMS verification code request failed: unknown status code: 17499 BILLING_NOT_ENABLED


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.


Solution

  • "Starting September 2024, to improve the security and service quality of Phone Authentication, Firebase projects must be linked to a Cloud Billing account to enable and use the SMS Service." From the Firebase FAQ.

    They recently sent a notice to customers that we are no longer supporting SMS on the Spark plan and that if you need to continue using SMS, you would need to upgrade to the Blaze plan Pricing plans.

    A new phone authentication policy: "Starting August 1, 2024 all projects using Firebase Phone Authentication (SMS) must be linked to a Cloud billing account". So it is now required to upgrade the subscription plan to Blaze to be able to use phone authentication for your project.

    What you need to do:

    Link your project to a Cloud Billing account if you plan to enable Phone Authentication, or currently have it enabled. By linking your Firebase project to a Cloud Billing account, the project will have access to more services and higher usage levels as described in the Pay-as-you-go Blaze plan.

    From now on all projects using Firebase Phone Authentication (SMS) must be linked to a Cloud Billing Account. And Also, in the Blaze plan there is still a no-cost 10 SMS sent each day quota. Any charges applicable to phone authentication will be incurred only after exceeding this limit.