如何解决OnCodeSent Firebase返回空字符串
我正在使用使用Firebase的电话身份验证将SMS发送到电话号码。它正在发送带有生成数字的短信,但是当执行OnCodeSent时,返回的字符串为null,因为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);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。