oncodesnt firebase返回空字符串

vsaztqbk  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(214)

我在用firebase的电话认证向一个电话号码发送短信。它用生成的数字发送sms,但是当执行onconfident时,返回的字符串为空,它也不会自动验证,因为onverificationcompleted也不会执行。

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);

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题