0

I'm using the Phone Authentication using Firebase to send SMS to a phone number. It's sending the sms with a generated number but when OnCodeSent is executed the string returned is null, it's not also auto-verifying since onVerificationCompleted not executed also.

 public static void sendVerificationCode(final Activity activity, final String mobileNumber)
{


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

            CommonMethods.createToast(activity.getApplicationContext(), "Verified");
        }

        @Override
        public void onVerificationFailed(@NonNull FirebaseException e) {

            CommonMethods.createToast(activity.getApplicationContext(), "Something went wrong, please make sure" +
                    " that you enter '+' before your country code");
        }

        @Override
        public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {

            super.onCodeSent(s, forceResendingToken);
            Log.i("verificationcode", s);
            Intent goToVerificationIntent = new Intent(activity, VerificationActivity.class);
            goToVerificationIntent.putExtra("codeSent", s);
            goToVerificationIntent.putExtra("mobileNumber", mobileNumber);
            activity.startActivity(goToVerificationIntent);
            activity.finish();
        }


    };


    PhoneAuthProvider.getInstance().verifyPhoneNumber(
            mobileNumber,
            60,
            TimeUnit.SECONDS,
            activity,
            mCallbacks);

}
Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
Sam
  • 291
  • 3
  • 17

0 Answers0