Check if user is authenticated for the first time in Firebase Google Authentication in Android

后端 未结 8 1443
一向
一向 2020-11-30 06:16

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

8条回答
  •  隐瞒了意图╮
    2020-11-30 06:46

    From the Firebase-ui docs, you can check the last sign-in timestamp against the created-at timestamp like this:

    FirebaseUserMetadata metadata = auth.getCurrentUser().getMetadata();
    if (metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp()) {
        // The user is new, show them a fancy intro screen!
    } else {
        // This is an existing user, show them a welcome back screen.
    }
    

提交回复
热议问题