react-native-twilio-chat
react-native-twilio-chat copied to clipboard
How to get media elements?
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