I am using Firebase Authentication in an Android application, and I am using Google account authentication as an option to sign in to the application.
How can I know
To check if it's the first time user logs in, simply call the AdditionalUserInfo.isNewUser() method in the OnCompleteListener.onComplete callback.
Example code below, be sure to check for null.
OnCompleteListener completeListener = new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
boolean isNew = task.getResult().getAdditionalUserInfo().isNewUser();
Log.d("MyTAG", "onComplete: " + (isNew ? "new user" : "old user"));
}
}
};
Check the docs for more reference AdditionalUserInfo