If 2 user is using the app, messages are being displayed on the left side of the screen. cannot differentiate between them (sender who sent what messages),It occurs only when use our own REST Api Call to onload,
But when send one new message at that time message will display separately sender and receiver format and one more scenario when i use twillio default getMessages method at that time also error won’t occur.
Twilio method to get Previous Messages on both user:
this.channel.getMessages(0).then((messages) => {
console.log("getMessages" + messages);
this.handleBatch(messages);
});
Please find screenshot above for your reference.Any one know how to fix this issue or any suggestions are welcome.
3
Answers
react-native-gifted-chat differentiates messages using user props, which specify
User sending the messages,
so you have to give user props as
name and avatar is useful for displaying name or image in gifted chat if you want
and onSend event send this user with text to twillio as
Now on your getMessages
before appanding gifted chat change message format as gifted chat want
only for example i m using state to set message
i hope it will help you.
if any query let me know.
try adding the user who is writting to the giftedChat:
Every message that has the user’s
_id: 'sarathy'
will be displayed on the right.example of message that will be displayed on the right side:
anyone having this issue Like me not looking to docs code properly… Do one thing … add _id in-place id… both message object in user props inside