更新时间:2021-11-20 21:03:38
要检查是否是用户首次登录,只需在OnCompleteListener.onComplete
回调中调用AdditionalUserInfo.isNewUser()
方法.
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<AuthResult> completeListener = new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
boolean isNew = task.getResult().getAdditionalUserInfo().isNewUser();
Log.d("MyTAG", "onComplete: " + (isNew ? "new user" : "old user"));
}
}
};
检查文档以获取更多参考信息 AdditionalUserInfo
Check the docs for more reference AdditionalUserInfo