4

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

Matt Leach
  • 839
  • 3
  • 10
  • 15
  • 1
    Matt Leach, Yes. Really basic thing and needed!!. @twilio-programmable-chat Should provide as soon as possible. – H_H Apr 23 '21 at 10:49
  • I'm going to be passive aggressive about it & send N+1 requests to Twilio api just to retrieve the friendly names of all the users of public chat of the app that i'm developing that will have thousands of users. – Raush Jun 02 '21 at 10:47

1 Answers1

4

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;
    });
});
Chenna
  • 2,383
  • 3
  • 20
  • 36