我目前正在制作一个 android 应用程序,我需要验证用户是否使用 OTP 输入了正确的手机号码。用户已经使用他的电子邮件和密码登录了应用程序。现在我需要验证用户输入的手机号码,而不使用 firebase 电话身份验证的 signInWithCrendntial() 方法。我该怎么做?
我的 mCallbacks 是
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
Toast.makeText(getApplicationContext(), "Verification Complete", Toast.LENGTH_SHORT).show();
showMessage("Success!!","OTP verified!" + credential);
cred = credential;
//btn_add_guest.setEnabled(true);
}
@Override
public void onVerificationFailed(FirebaseException e) {
Toast.makeText(getApplicationContext(), "Verification Failed", Toast.LENGTH_SHORT).show();
Log.i(TAG,"Error is "+e.getMessage());
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
Toast.makeText(getApplicationContext(), "Code Sent", Toast.LENGTH_SHORT).show();
mVerificationId = verificationId;
mResendToken = token;
Log.i(TAG,"VERFICATION ID IS"+mVerificationId);
Log.i(TAG,"RESEND TOKEN"+mResendToken);
btn_add_guest.setEnabled(false);
}
};
Run Code Online (Sandbox Code Playgroud)
我在按钮 Pressed 上调用此方法,其中 put_otp 是用户输入 OTP 的 textView。
verifyPhoneNumberWithCode(mVerificationId,put_otp.getText().toString()); …Run Code Online (Sandbox Code Playgroud)