0
votes

I am using firebase email-password auth system. After login, a user can send message and I store it like as

{
    "uid":"14sr3424234234223456266",
    "date":"2016-12-02",
    "time":"23:29:55",
    "message": "hello friend"
}

I want to show the chat list in a list like displyName says: message but in my message object, i have the only uid of a user. How can display user displayName from my registered user list by uid.

2

2 Answers

0
votes

You can retrieve User Information (i.e. name, email etc.) only for currently signed In user (using firebase.auth().currentUser object in javascript).

If you want to display name of the User who has created that message I would recommend to store name of that User instead of uid in message object itself.

Hope this helps!!

0
votes

You will have to store the displayName as that user's email if you are using the email password system, or by using the google sign in system you can access the display name properly.

{
"displayName":firebase.auth().currentUser().displayName,
"date":"2016-12-02",
"time":"23:29:55",
"message": "hello friend"
}

Hope this alteration helps!