I am working on an Android application where I just want to check my mobile phone number without creating a user account. Is it possible? I am using the following code
private void startPhoneNumberVerification(String phoneNumber) {
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
this,
mCallbacks);
}
private void verifyPhoneNumberWithCode(String verificationId, String code) {
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
signInWithPhoneAuthCredential(credential);
}
The following function will create a user account if the user account is not there, but I do not want to create an account, I just want to check the code entered by the user. Is there any callback method for this?
private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
dialog.dismiss();
FirebaseUser user = task.getResult().getUser();
Toast.makeText(LoginActivity.this, "Success " + user.getEmail(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(LoginActivity.this, "Failed ", Toast.LENGTH_SHORT).show();
verifyPhoneNumberWithCode(mVerificationId, editText.getText().toString().trim());
}
}
});
}
source
share