get History Messages
Retrieves a list of messages in the conversation that meet the specified criteria.
The returned messages do not include the message corresponding to oldestMessageId. If the number of messages in the conversation is less than the value of the count parameter, all messages in the conversation will be returned.
For example, if oldestMessageId is 10 and count is 2, the method will return a list of Message objects with messageIds 9 and 8.
Note: This method does not support fetching historical messages for chatrooms CHATROOM.
This method only retrieves messages from the local database.
Note: Starting from version 5.4.4, this method supports the ultra group type. Ultra groups do not receive offline messages. Calling this method for ultra groups may result in message gaps. Use the message gap interface to retrieve ultra group messages.
Since
5.1.1
Parameters
The type of conversation . Chatrooms are not supported.
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The business identifier of the conversation to which the message belongs.
The type identifier of the message.
The ID of the last message. This method retrieves the count number of messages before this message. Set to -1 for the first call when there are no messages.
The number of messages to retrieve.
The callback for retrieving historical messages, ordered from newest to oldest.
Retrieves a list of messages in the conversation that meet the specified criteria.
For example, to retrieve the 10 image messages before the message with messageId 22, the corresponding parameters would be: getHistoryMessages(conversationType, targetId, RC:ImgMsg, 22, 10, true, resultCallback).
Note: This method does not support fetching historical messages for chatrooms CHATROOM.
This method only retrieves messages from the local database.
Note: Starting from version 5.4.4, this method supports the ultra group type. Ultra groups do not receive offline messages, and calling this method for ultra groups may result in missing messages. Please use the missing message interface to retrieve messages for ultra groups.
Since
5.1.1
Parameters
The type of conversation . Chatrooms are not supported.
The conversation ID. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The business identifier for the conversation to which the message belongs.
The message type identifier. For example, RC:TxtMsg, RC:ImgMsg, RC:VcMsg, etc. value.
The starting message ID.
The number of messages to retrieve.
The direction of the messages relative to the baseMessageId . The specified baseMessageId is used as the starting point. Messages earlier than baseMessageId are FRONT, and messages later are BEHIND.
The callback for retrieving historical messages, ordered from newest to oldest.
Retrieves a list of messages that meet the specified criteria in the conversation.
For example, to retrieve the 10 image and text messages before the message with messageId 22, the objectNames should be a List of strings like:
objectNames.add(RC:ImgMsg);
objectNames.add(RC:TxtMsg);
The corresponding parameters would be: getHistoryMessages(conversationType, targetId, objectNames, 22, 10, true, resultCallback).
This method only retrieves messages from the local database.
Note: Since version 5.4.4, this method supports the ultra group type. Ultra groups do not receive offline messages, and calling this interface for ultra groups may result in message gaps. Please use the gap message interface to retrieve ultra group messages.
Since
5.1.1
Parameters
The type of conversation , chatrooms are not supported.
The conversation ID. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The business identifier of the conversation to which the message belongs.
A List of message type identifiers. For example, RC:TxtMsg, RC:ImgMsg, RC:VcMsg, etc.
The timestamp of the current message.
The number of messages to retrieve.
The direction of the messages to retrieve relative to the current message io.rong.imlib.RongCommonDefine.GetMessageDirection Using the current message as the starting point, messages before the current message are FRONT, otherwise they are BEHIND.
The callback for retrieving historical messages, ordered from newest to oldest.
Retrieves the latest message entities of the specified type from a conversation, starting before a specified message and limited by a specified count.
Note: This method does not support chatrooms!
This method only retrieves messages from the local database.
Note: Since version 5.4.4, this method supports ultra group types. Ultra groups do not receive offline messages, and calling this method for an ultra group may result in message gaps. Use the message gap interface to retrieve messages for ultra groups.
Since
5.1.1
Parameters
The type of conversation. Chatrooms are not supported. Refer to Conversation.ConversationType.
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The business identifier of the conversation to which the message belongs.
The ID of the last message. Retrieve `count` messages before this message. Set to -1 for the first call when no messages are available.
The number of messages to retrieve.
The callback for retrieving historical messages, ordered from newest to oldest.
Searches for a specified number of messages before before
and after
after
a specified message in a conversation.
The returned message list will include the specified message. The messages are ordered from newest to oldest.
This method only retrieves messages from the local database.
Note: Starting from version 5.4.4, this method supports ultra group type. Ultra groups do not receive offline messages. Calling this method for ultra groups may result in missing messages. Use the missing message interface to retrieve ultra group messages.
Since
5.1.1
Parameters
The specified conversation type.
The specified conversation ID.
The business identifier of the conversation to which the message belongs.
The sending time of the specified message, which cannot be 0.
The number of messages before the specified message.
The number of messages after the specified message.
The callback for search results.
When loading more messages, the returned data includes the current message. For example: if the current message ID is 500, before = 0, and after = 10, the returned messages will be from 510 to 500, sorted in descending order by message ID.