react-native-twilio-chat icon indicating copy to clipboard operation
react-native-twilio-chat copied to clipboard

How to get media elements?

Open rahmanharoon opened this issue 3 years ago • 0 comments

I have tried this code and i also done image upload feature,

Here is the messages data am getting:

{
createdAt: Thu Dec 23 2021 12:56:23 GMT+0530 (India Standard Time) {}
received: true
text: "Hai"
user: {_id: "Ghost", name: "Ghost"}
_id: '1'
}, 
{
createdAt: Thu Dec 23 2021 12:56:23 GMT+0530 (India Standard Time) {}
received: true
text: null
user: {_id: "Ghost", name: "Ghost"}
_id: '2'
}

the second object of _jd 2 contains media elements and i can see the media objects on console before parsing,

useEffect(() => {
      TwilioService.getInstance()
        .getChatClient()
        .then((client: any) => client.getChannelBySid(channelId))
        .then((channel: any) => setChannelEvents(channel))
        .then((currentChannel: any) => currentChannel.getMessages())
        .then((paginator: any) => {
          chatMessagesPaginator.current = paginator;
          const newMessages = TwilioService.getInstance().parseMessages(
            paginator.items,
          );
          console.log(newMessages, "newMessages", paginator.items)
          setMessages(newMessages);
        })
        .catch((err: any) =>
          showMessage({message: err.message, type: 'danger'}),
        )
        .finally(() => setLoading(false));
    }, [channelId, setChannelEvents]);

in paginator.items i can see the type: 'media' and media url inside the state,

Is their any way to get media object along with messages

rahmanharoon avatar Dec 23 '21 09:12 rahmanharoon