Fetch Messages returns Empty array


When fetching all messages for a logged in user, the API returns an empty array. I have been sending messages successfully, I can see the messages in the Comet Chat dashboard. When I try and get all the messages for a user I just get an empty array.

Please note, the “getConversations” api is working fine for me.

Im using:
@cometchat-pro/react-native-calls”: “2.0.2”,
@cometchat-pro/react-native-chat”: “2.3.4”,

var limit = 50;

var messagesRequest = new CometChat.MessagesRequestBuilder()

  messages => {
    console.log("Message list fetched:", messages);
    // Handle the list of messages
  error => {
    console.log("Message fetching failed with error:", error);

Hello @densocial,

Currently, it is not possible to fetch messages from all the users. You need to specify the UID of a user or GUID of a group while fetching messages using the setUID(UID) or setGUID(GUID) method of the MessagesRequestBuilder.

Can you please let us know why are you fetching messages of all the users at once?

Warm Regards,

CometChat Pro
Mayur Bhandari

Hi Mayur,

Thanks for your response.

I do not want to fetch all the messages for all the users. I just want to fetch all the messages for the logged in user. Currently im fetching all the conversations, then looping through the conversations and getting the messages for those conversations. This is a little slow… Is there a better way to fetch all messages for the logged in user?