Bug? React Native FileMessageParams with extra data


I’m having some problems while trying to send extra data in the FileMessageParams message.

I have something like this:

  let messageData = new this.sendBird.FileMessageParams()
  messageData._fileUrl = 'A photo URL'
  messageData.customType = 'MY_CUSTOM_TYPE'
  messageData.data = "some string"

When I invoke:
channel.sendFileMessage( messageData, (item, error) => {

The item returned is right. Have its data parameter well formated.

But if I exit the app and then I enter again, in the createPreviousMessageListQuery, everything is fine but the data parameter is empty. Looks like a bug, but I’m not sure about it :face_with_head_bandage:

I’ve tried to fill the messageData.data with a plain string, with an encoded JSON, with numbers in string format, but there’s no way to recover again the data field option when calling createPreviousMessageListQuery.

Could you help me with this, please?
Thanks!! Regards


I played with this in the sample application, and when I set messageData.data to a string, its included in the list of message that are generated about the chat room.

Now granted, I’m using basic JS here, but this is what I had:

const fileMessageParams = new this.sb.FileMessageParams();
fileMessageParams.file = file;
fileMessageParams.thumbnailSizes = thumbnailSizes;
fileMessageParams.data = 'exampleDataString';

When I generated the message list in the room, I did see the data in the returned object:

channelType: "group"
createdAt: 1593429437242
customType: "" 
data: "exampleDataString"
errorCode: 0

Thank you Tyler,

I’ll check if it’s related to the way I call FileMessageParams, by passing directly the _fileUrl parameter

If you console out the response on the actual update of the FileMessageParams, does the returned object include the intended data?

Once I send the message I print the item created:

channel.sendFileMessage( messageData, (item, error) => {
        console.log('Item created', item);

At this point, the data field is filled right.

Item created {"_sender": {"_preferredLanguages": null, "connectionStatus": "nonavailable", "friendDiscoveryKey": null, "friendName": null, "isActive": true, "isBlockedByMe": false, "lastSeenAt": 0, "metaData": {"name": "Josue", "picture": "XXX"}, "nickname": "josue", "profileUrl": "XXX", "userId": "XXX"}, "channelType": "group", "channelUrl": "sendbird_group_channel_XXX", "createdAt": 1593511766368, "customType": "PRIVATE_REQUEST_ACCEPTED", "**data": "348527947",** "errorCode": 0, "mentionType": "users", "mentionedUsers": [], "messageId": 348536134, "messageSurvivalSeconds": -1, "messageType": "file", "metaArrays": [], "name": "", "parentMessageId": 0, "parentMessageText": null, "reactions": [], "reqId": "1593511373192", "requestState": "succeeded", "requestedMentionUserIds": [], "requireAuth": false, "sendingStatus": "succeeded", "silent": false, "size": 0, "threadInfo": {"lastRepliedAt": 0, "mostRepliedUsers": [], "replyCount": 0, "updatedAt": 0}, "thumbnails": [], "type": "", "updatedAt": 0, "url": "XXX"}

But if I reload the app and call createPreviousMessageListQuery, this field is empty

{"_sender": {"_preferredLanguages": null, "connectionStatus": "nonavailable", "friendDiscoveryKey": null, "friendName": null, "isActive": true, "isBlockedByMe": false, "lastSeenAt": 0, "metaData": {"name": "Josue", "picture": "XXX"}, "nickname": "josue", "profileUrl": "XXX", "userId": "XXX"}, "channelType": "group", "channelUrl": "XXX", "createdAt": 1593511766368, "customType": "PRIVATE_REQUEST_ACCEPTED", **"data": ""**, "errorCode": 0, "mentionType": "users", "mentionedUsers": [], "messageId": 348536134, "messageSurvivalSeconds": -1, "messageType": "file", "metaArrays": [], "name": "", "parentMessageId": 0, "parentMessageText": null, "reactions": [], "reqId": "1593511373192", "requestState": "succeeded", "requestedMentionUserIds": [], "requireAuth": false, "sendingStatus": "succeeded", "silent": false, "size": 0, "threadInfo": {"lastRepliedAt": 0, "mostRepliedUsers": [], "replyCount": 0, "updatedAt": 0}, "thumbnails": [], "type": "", "updatedAt": 0, "url": "XXX"}

Everything looks ok, but this field :sweat_smile:

I’ll continue looking for it

Other things I’ve tried:

  • The data field with sendUserMessage works perfectly! So the problem must be related with the FileMessage
  • I’ve tried to update the FileMessageParams once is sent (to try if a different function such update works) but the result is the same
  • I decided to make a workaround by using metaArrays by this way:

messageData.metaArrays=[new this.sendBird.MessageMetaArray('potato')]

But happens exactly the same with this field, everything looks ok but when I recover i, metaArrays is empty too :exploding_head:

Note: I tried with includeMetaArray enabled and disabled, but no results…

let messageListQuery = this.channel.createPreviousMessageListQuery()
    messageListQuery.includeMetaArray = true;

@PicTime Can you just confirm for me what you mean by reload the app?
I shut down the application last night after testing the my original post. I started it up just now to see if reloading it had the data field disappear, however in both regular and incognito browsers, the data field is still populated with the exampleDataString from the original creation.

This is utilizing the web-basic-sample app.

Would you mind just validating that this works in the sample application to ensure that I’m not crazy? In the sample application I added the data to sendFileMessage() in SendBirdAction.js just after line 321. I then added a console.log() on line 292 for the getMessageList() which calls the createPreviousMessageListQuery().

I just want to ensure you and I see the same behavior in the sample application so we can focus on what may be potentially different with your use case.

The functions I mentioned in my previous most now look like this:

getMessageList(channel, isInit = false) {
      if (isInit || isNull(this.previousMessageQuery)) {
        this.previousMessageQuery = channel.createPreviousMessageListQuery();
      return new Promise((resolve, reject) => {
        if (this.previousMessageQuery.hasMore && !this.previousMessageQuery.isLoading) {
          this.previousMessageQuery.load(50, false, (messageList, error) => {
            error ? reject(error) : resolve(messageList);
        } else {

sendFileMessage({ channel, file, thumbnailSizes, handler }) {
    const fileMessageParams = new this.sb.FileMessageParams();
    fileMessageParams.file = file;
    fileMessageParams.thumbnailSizes = thumbnailSizes;
    fileMessageParams.data = 'exampleDataString';

    return channel.sendFileMessage(fileMessageParams, (message, error) => {
      if (handler) handler(message, error);

A clarification: as the title describes I’m using a React Native implementation, maybe that’s what causes the difference :face_with_head_bandage:
(So, when I say that I’m reloading the app, I’m literally reloading/reinstalling it)

I used a network logger, and I detected that the creation process of the message is working perfectly. And when I rescue the message list, the param is properly returned in the GET request, as you can see in the purple arrow:

The content of that purple arrow is what I actually want. But using the same function you use:

The content returned doesn’t have the string:

{"_sender": {"_preferredLanguages": null, "connectionStatus": "nonavailable", "friendDiscoveryKey": null, "friendName": null, "isActive": true, "isBlockedByMe": false, "lastSeenAt": 0, "metaData": [Object], "nickname": "josue", "profileUrl": "XXX", "userId": "XXX"}, "channelType": "group", "channelUrl": "XXX4998d3", "createdAt": 1593599901380, "customType": "PRIVATE_REQUEST_ACCEPTED", "data": "", "errorCode": 0, "mentionType": "users", "mentionedUsers": [], "messageId": 349800257, "messageSurvivalSeconds": -1, "messageType": "file", "metaArrays": [], "name": "", "parentMessageId": 0, "parentMessageText": null, "reactions": [], "reqId": "1593599844663", "requestState": "succeeded", "requestedMentionUserIds": [], "requireAuth": false, "sendingStatus": "succeeded", "silent": false, "size": 0, "threadInfo": {"lastRepliedAt": 0, "mostRepliedUsers": [Array], "replyCount": 0, "updatedAt": 0}, "thumbnails": [], "type": "", "updatedAt": 0, "url": "XXX"}

So, I guess somewhere inside the SDK, the content returned from the network is being changed and is inside that process when something is not working (or maybe I’m missing something).

For example, the sendbird endpoint returns a ‘file’ object at network level, but the load method of createPreviousMessageListQuery is not returning that structure, instead, all those ‘file’ parameters are in the same level, maybe is there where the data field is being cleared :S

The response object that you’re showing in the screenshot looks interesting. On both the object that is returned on creation, and what is listed when calling createPerviousMessageListQuery() are structured like this:

It seems to be that the reason here is that on your creation, you’re somehow stacking things onto a file object that doesn’t appear to actually exist in the database. Would it be possible to see your entire creation method?

Know what? If I force the package.json to use an older version of sendbird (exactly 3.0.90), the data string is returned and it works fine :pleading_face:

BTW: Happens the same with the code of github: https://github.com/sendbird/SendBird-JavaScript/tree/master/web-basic-sample

If I use the latest version, the string is not returned, but with an older one, it works perfectly, so it’s no a React Native thing after all. Maybe something has changed in the latests releases but I didn’t noticed nothing in the API docs

What version of the SDK where you using when this was not functioning?

The latest one: 3.0.127

I’m going to check the latest version when it works

I was using 3.0.111, but did just update the sample application to 3.0.127, and I now experience a similar issue.

My returned object on creation looks correct, and is still different from what yours (Note, no file object):

However this time, when calling the createPerviousMessageListQuery(), my data entry is now also blank:

Looking at the changlog on Github, there have been some changes to FileMessage but nothing that should be causing this.

@PicTime I submitted a case with the support team. Case 00004213 in case you need to reference it for anything. I’ll let you know what comes of it.


Thank you Tyler! As my string said, your are awesome! :smile:

Have a nice day and thanks for your time!!

Hi @PicTime and @Tyler - Sendbird here! We’re taking a look.

1 Like

This issue has been shared with our JavaScript Team to address it.


Much appreciated @janna-sendbird!


Our JavaScript team is working on this item for improvement in the next release. Thank you @PicTime and @Tyler for reporting.