我有一个带有Firebase的Android Studio项目,我已经正确实现了Firebase。
im trying to make a sign in with sms authentication, everything works but no sms arrives
我已经配置了Firebase身份验证
这是一些代码
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
Toast.makeText(MainActivity.this, "Verification Complete", Toast.LENGTH_SHORT).show();
}
@Override
public void onVerificationFailed(FirebaseException e) {
Toast.makeText(MainActivity.this, "Verification Failed", Toast.LENGTH_SHORT).show();
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
Toast.makeText(MainActivity.this, "Code Sent", Toast.LENGTH_SHORT).show();
}
};
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.bt_send_otp:
PhoneAuthProvider.getInstance().verifyPhoneNumber(
etPhone.getText().toString(), // Phone number to verify
1, // Timeout duration
TimeUnit.MINUTES, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
break;
case R.id.bt_resend_otp:
break;
case R.id.bt_verify_otp:
break;
}
}
当我按下send otp按钮时,出现“代码已发送”的吐司
谢谢您的帮助 :)
Since it is a test number,
OTP
will not arrive. Though for testing you can use the verification code you added with the test phone number on the console.Firebase Console Dashboard
->Authentication
->SignIn Method
->Phone
->Phone numbers for testing
.Check out the docs for
Firebase Phone Verification
forAndroid
: https://firebase.google.com/docs/auth/android/phone-auth?authuser=1#test-with-whitelisted-phone-numbers