Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase get the first and last name [duplicate]

My Question:

I made a little Android App, where you can sign up and login with the firebase auth system. I made it like:

private FirebaseAuth firebaseAuth;
firebaseAuth = FirebaseAuth.getInstance()

then i used firebaseAuth.signinwithEmailAndPassword. Now my question: can i get the First name and the Last name from the user's email account? Like in youtube at the comments: example:

Firstname Lastname: Nice video

That not the email address is here, but the First and Last name, Greetings

like image 589
Simon Steinkellner Avatar asked Feb 12 '17 15:02

Simon Steinkellner


1 Answers

You can get the user's name from their profile. From the Firebase documentation on reading the user profile:

To get a user's profile information, use the accessor methods of an instance of FirebaseUser. For example:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
    // Name, email address, and profile photo Url
    String name = user.getDisplayName();
    String email = user.getEmail();
    Uri photoUrl = user.getPhotoUrl();

    // Check if user's email is verified
    boolean emailVerified = user.isEmailVerified();

   // The user's ID, unique to the Firebase project. Do NOT use this value to
    // authenticate with your backend server, if you have one. Use
    // FirebaseUser.getToken() instead.
    String uid = user.getUid();
}
like image 80
Frank van Puffelen Avatar answered Oct 26 '22 16:10

Frank van Puffelen