Hi!
I’m using “sendbird”: “3.1.9” at React Native project, when I’m trying to addReaction I’m getting an error without description what is the problem
Hi @aleksandr.bolshakov, it looks like maybe the order of the callback parameters is reversed. The “error” you received is actually a successful response.
Is this the only function that returns results in this order? Meaning its structured as (event, err) but is returned (err, event)?
Hi, @Tyler
may be but I used it as documentaion says
from /sendbird/SendBird.d.ts:
type reactionEventCallback = (event: ReactionEvent, error: SendBirdError) => void;
and reactions array from message remains empty
My apologies for my delayed response. I totally understand that you followed the documentation. Ideally I’m just checking to see if you get the correct information if you flip them. I tested this in my own sample application and I was getting the correct order in a non React-Native environment so I need to test in React Native.
@Tyler this is the message I’m trying to add a reaction to
@Tyler After message I refetched messages and reactions: [],
Looks like I’ll need to do some reproducing of the issue in my own environment. One thing I might suggest, is inspecting the network request that is being sent to see if it actually includes the data you’re expecting. I’ll report back once I’ve had a chance to try and reproduce this.
Just wanted to touch base on this topic. I was able to reproduce this in React-Native and am currently working with our Engineering team to understand what is going on.
Hey @aleksandr.bolshakov,
Just wanted to touch base on this. Are you calling sb.setErrorFirstCallback(true)
anywhere? I went back and look at our sample, and it is setting that which is why I was able to reproduce this. By removing it, I’m no longer able to reproduce this issue.
Hi @Tyler !
Thank you for your help!
yes with removing this sb.setErrorFirstCallback(true)
problem goes away BUT I still getting empty reactions array when fetching messages
how it’s looks like:
- I sending reaction,got no error and reactionEvent:
- call
message.applyReactionEvent(reactionEvent);
- but when I refetching messages, at this message
rections
array sill empty
Apologize for my delayed response. When you generate your listQuery, are you passing in includeReaction = true
?
An example like:
const listQuery = groupChannel.createPreviousMessageListQuery();
listQuery.limit = LIMIT;
listQuery.reverse = REVERSE;
listQuery.includeReaction = true; // Retrieve a list of messages along with their reactions.
Hi @Tyler!
Sorry for long response, yes I am passing includeReaction = true
Can you share with me your entire createPreviousMessageListQuery? Also, can you console it out as well and confirm that it is in fact being set to true?
I’m able to reproduce this behavior in my own application. When I react to a message, I can see the message when I fetch the message list so long as includeReactions
is true.
Is this occurring in a production app or staging app?
For transparency sake here is my test:
const params = new sendbird.MessageListParams();
params.isInclusive = true;
params.includeReactions = true;
channel.getMessagesByMessageId(1915615880, params, (messages, error) => {
if (error) {
console.error('WE ERRORED ON THIS', error);
} else {
console.log('-----------------------------');
console.log(JSON.stringify(messages[0], null, 2));
console.log('-----------------------------');
}
});
Which outputs:
LOG -----------------------------
LOG {
"messageId": 1915615880,
"messageType": "user",
"channelUrl": "sendbird_group_channel_71815291_42f02f6711993591c5e4cfad473e882686eea0ce",
"data": "",
"customType": "",
"silent": false,
"createdAt": 1655372815096,
"updatedAt": 0,
"channelType": "group",
"metaArrays": [],
"reactions": [
{
"key": "👍",
"userIds": [
"testUser02"
],
"updatedAt": 1655380310954,
"_version": {
"testUser02": 1655380310954
}
}
],
"mentionType": "users",
"mentionedUsers": [],
"mentionedUserIds": [],
"mentionedMessageTemplate": null,
"sendingStatus": "succeeded",
"parentMessageId": 0,
"parentMessageText": null,
"threadInfo": {
"replyCount": 0,
"mostRepliedUsers": [],
"lastRepliedAt": 0,
"updatedAt": 0
},
"isReplyToChannel": false,
"parentMessage": null,
"ogMetaData": null,
"isOperatorMessage": false,
"appleCriticalAlertOptions": null,
"reqId": "1655372773101",
"_isAutoResendRegistered": false,
"message": "Hello World. This is a message with chat history enabled.",
"_sender": {
"nickname": "Admin",
"plainProfileUrl": "https://randomuser.me/api/portraits/men/46.jpg",
"userId": "Admin",
"connectionStatus": "nonavailable",
"lastSeenAt": 0,
"metaData": {},
"isActive": true,
"friendDiscoveryKey": null,
"friendName": null,
"_preferredLanguages": null,
"requireAuth": false,
"role": "none",
"isBlockedByMe": false
},
"translations": {},
"requestState": "succeeded",
"requestedMentionUserIds": [],
"errorCode": 0,
"messageSurvivalSeconds": -1,
"plugins": [],
"poll": null,
"_messageParams": null
}
LOG -----------------------------
Issue solved!
Thanks!
Also
params.includeReactions = true;
should be added to the
getMessagesByMessageId