is there any function in firebase Google Auth package for flutter to find the date of the creation of user?

0

Issue

i want to get the user creation timestamp, is there any way to do this?
im using google sign in auth.
Any help is appreciated!

Edit: i cant find the user creation timestamp when printing the whole user

Edit 2: Code I am using for authentication:

  GoogleSignInAccount currentUser;


final GoogleSignIn googleSignIn = GoogleSignIn();
final FirebaseAuth auth = FirebaseAuth.instance;

Future<FirebaseUser> signIn() async {
  GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
  GoogleSignInAuthentication gSA = await googleSignInAccount.authentication;
  FirebaseUser user = await auth.signInWithGoogle(
      idToken: gSA.idToken, accessToken: gSA.accessToken);

  print('Signed In as ${user.displayName}');
  return user;
}

Solution

You can get the creation timestamp in epoch format with:

user.metadata.creationTime

See:
metadata

Answered By – Swift

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More