FireBaseUI Auth - how to know if account is from a new signup or existing user?

后端 未结 2 2134
野趣味
野趣味 2020-12-17 06:24

I am using firebaseUI for authentication. it essentially opens a a external activity and logs the user into firebase and sends the developer a call back in onActivityResult.

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-17 06:54

    public boolean isNewSignUp(){
            FirebaseUserMetadata metadata = mAuth.getCurrentUser().getMetadata();
            return metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp();
        }
    

    At the time of writing, Looks like each logged in user has meta data as i suspected. we can check the last sign time to know if its a new account. I heard they will be making this easier in the future, check later versions of firebase authentication before attempting this.

提交回复
热议问题