问题描述
我正在研究 Firebase 身份验证 OTP 它工作正常但是一些设备的 oncodesend 函数没有直接调用 onVerificationCompleted 由于这个原因 他们不能注册。 这是我的代码检查为什么这不适用于所有设备
public void onSignupSuccess() {
_signupButton.setEnabled(true);
ProgressDialog progressDialog= new ProgressDialog(signup_with_gmail.this,R.style.Theme_AppCompat_DayNight_Dialog_MinWidth);
progressDialog.setIndeterminate(true);
progressDialog.setTitle("OTP Verification");
progressDialog.setMessage("Sending...");
progressDialog.show();
progressDialog.setCancelable(false);
auth = FirebaseAuth.getInstance();
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallback = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Toast.makeText(signup_with_gmail.this,"verification completed"+phoneAuthCredential,Toast.LENGTH_SHORT).show();
if(verificationCode!=null)
{
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationCode,phoneAuthCredential.getSmsCode());
SigninWithPhone(credential);
}
}
@Override
public void onVerificationFailed(FirebaseException e) {
progressDialog.dismiss();
Toast.makeText(signup_with_gmail.this,""+e.getMessage(),Toast.LENGTH_SHORT).show();
}
@Override
public void onCodeSent(String s,PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s,forceResendingToken);
verificationCode = s;
progressDialog.dismiss();
Toast.makeText(signup_with_gmail.this,"Code sent",Toast.LENGTH_SHORT).show();
dialog = new Dialog(signup_with_gmail.this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
dialog.setContentView(R.layout.verification_otp);
Button verify=dialog.findViewById(R.id.verify_button);
PinView otpcode=dialog.findViewById(R.id.pin_view);
verify.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String code=otpcode.getText().toString();
if(code.isEmpty())
{
Toast.makeText(getApplicationContext(),"Please Enter Code ",Toast.LENGTH_LONG).show();
}else
{
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationCode,otpcode.getText().toString());
SigninWithPhone(credential);
}
}
});
Window window = dialog.getwindow();
dialog.setCanceledOnTouchOutside(false);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
dialog.show();
}
};
PhoneAuthProvider.getInstance().verifyPhoneNumber(
ccp.getFullNumberWithPlus(),// Phone number to verify
60,// Timeout duration
TimeUnit.SECONDS,// Unit of timeout
signup_with_gmail.this,// Activity (for callback binding)
mCallback); // OnVerificationStateChangedCallbacks
}
任何人请指导我此代码在某些设备上运行良好,但在某些设备上不起作用
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)