get History Messages
Retrieves the latest message entities of the specified message type, before the specified message, and in the specified quantity from the conversation.
Since
5.0.0
Parameters
The conversation type. Refer to .
The conversation ID. Depending on the conversationType, it could be a user ID, discussion group ID, or group ID.
The ID of the last message. Retrieves the count number of messages before this message. Set to -1 for the first call when no messages exist.
The number of messages to retrieve.
The callback for retrieving historical messages, sorted in chronological order from newest to oldest.
Retrieves a list of messages in the conversation that meet the specified criteria.
For example, to get the 10 image and text messages before the message with messageId 22, the objectNames would be a List of strings:
objectNames.add(RC:ImgMsg);
objectNames.add(RC:TxtMsg);
The corresponding parameters would be: getHistoryMessages(conversationType, targetId, objectNames, 22, 10, true, resultCallback).
Since
5.0.0
Parameters
The type of conversation. Refer to .
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
A List of message type identifiers. For example, a List containing 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 RongCommonDefine.GetMessageDirection. Use FRONT to retrieve messages older than the current message, or BEHIND for newer messages.
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 messages before the message with messageId 22, the corresponding parameters would be: getHistoryMessages(conversationType, targetId, RC:ImgMsg, 22, 10, true, resultCallback).Note: The SDK clears the chatroom's historical messages when exiting the chatroom, so retrieving chatroom history after exiting will return an empty list.
Since
5.0.0
Parameters
The type of conversation Conversation.ConversationType
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
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 Using the specified baseMessageId 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.
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 messageId 9 and 8.Note: The SDK clears the chatroom's historical messages when exiting the chatroom. Therefore, when retrieving historical messages after exiting, the returned list will be empty.
Since
5.0.0
Parameters
The type of conversation Conversation.ConversationType.
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The message type identifier.
The ID of the last message. Retrieves the count messages before this message. Set to -1 for the first call when no messages exist.
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 and after a given message in a conversation.
The returned message list includes the specified message. Messages are ordered from newest to oldest.
Since
5.0.0
Parameters
The type of the specified conversation.
The ID of the specified conversation.
The send 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.
Callback for the 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, it returns messages from 510 to 500, ordered by message ID in descending order.
Deprecated
Retrieves a list of messages in the conversation that meet the specified criteria.
Return
A list of historical messages, ordered from newest to oldest.
Since
5.0.0
Deprecated
This method is deprecated. It is recommended to use getHistoryMessages or getHistoryMessages for asynchronous operations.
Parameters
The type of conversation Conversation.ConversationType
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The identifier for the message type.
The ID of the last message, used to fetch the previous `count` messages. Set to `-1` for the first call when no messages are available.
The number of messages to retrieve.
Deprecated
Retrieves a list of messages in the conversation that meet the specified criteria.
For example, to get the 10 image and text messages before the message with messageId 22, where objectNames is a List of strings:
objectNames.add(RC:ImgMsg);
objectNames.add(RC:TxtMsg);
The corresponding parameters would be: getHistoryMessages(conversationType, targetId, objectNames, 22, 10, true, resultCallback).
Return
A list of historical messages, sorted from newest to oldest.
Since
5.0.0
Deprecated
This method is deprecated. It is recommended to use getHistoryMessages or getHistoryMessages for asynchronous operations.
Parameters
The type of conversation. Refer to .
The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.
The ID of the last message. Retrieves the count messages before this message. Set to -1 for the first call when no messages exist.
The number of messages to retrieve.