I am using firebase phone Authentication . When a user creates a account using phone number and next time he creates account with same phone number Than I want to show a m
This is very easy way to check whether a user is already register with firebase.
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
FirebaseUser user = mAuth.getCurrentUser();
if(task.getResult().getAdditionalUserInfo().isNewUser()){
register(user);
}else{
Intent intent = new Intent(LoginActivity.this,MainActivity.class);
startActivity(intent);
}
Toast.makeText(LoginActivity.this, "welcome"+user.getDisplayName(), Toast.LENGTH_SHORT).show();
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(LoginActivity.this, "signin Failed", Toast.LENGTH_SHORT).show();
}
// ...
}
});