Lamberto Basti
Lamberto Basti

Reputation: 476

How do I retrieve user's name and last name using FirebaseUI in Android?

According to this guide the built-in authentication of FirebaseUI should already handle this. Indeed, retrieving the current user and calling currentUser.displayName (Kotlin here) the string returned is "Lamberto Basti" that is my name concatenated with my last name. Is there a smart way to retrieve them separately? Notice that I've enabled login with email, Facebook, Google and Twitter.

Upvotes: 2

Views: 2728

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598847

There is no API to get the separate first name and last name from Firebase Authentication. If you need the name in that format, you will need to ask your user for them (potentially pre-populating the UI based on their display name).

Note that splitting the string on a space to get the first name and last name may work in your tests, but will likely lead to problems as you roll out internally. To learn more about the intricacies, I recommend reading the W3C treatise about personal names around the world.

Upvotes: 3

Related Questions