Twilio programmable chat message user friendlyName

Viewed 744

I am using Twilio Programmable Chat to add a chat feature to my mobile app built in React Native. I'm using the JS client SDK for this.

When the app receives a new message, the data that comes through uses the user identity for the author field. Is there away to include the friendlyName in the payload so I can display this to the user.

I could make a separate request for all users and find the correct user within the app but it would be great if this data could just be on the same request.

Thanks for any help

1 Answers

Yes, only author field present in new message event, I used an alternate approach

channelMembersDict = {}
// Assuming you have set selected an Channel
this.activeChannel.getMembers().then(members => {
  members.forEach(mem => {
    //member contains friendlyName attribute
    this.channelMembersDict[mem.state.identity] = mem; 

    //If you really want user then
    mem.getUser().then(user => {
      this.channelMembersDict[mem.state.identity] = user;
    });
});
Related