Twilio可编程聊天消息用户friendlyName

时间:2019-06-15 09:48:28

标签: react-native twilio chat twilio-programmable-chat

我正在使用Twilio可编程聊天功能向我在React Native中构建的移动应用程序添加聊天功能。我正在为此使用JS客户端SDK。

当应用收到新消息时,传入的数据将使用作者字段的用户身份。是否有需要在有效载荷中包含friendlyName,以便我可以向用户显示。

我可以向所有用户发出单独的请求,并在应用程序中找到正确的用户,但是如果这些数据可以仅在同一请求上,那将是很好的选择。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

是的,在新邮件事件中仅存在author个字段,我使用了另一种方法

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;
    });
});
相关问题