getHistoryMessages

public abstract void getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)

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 messageId 9 and 8.

Parameters

conversationType

The type of conversation Conversation.ConversationType

targetId

The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.

objectName

The message type identifier.

oldestMessageId

The ID of the last message. This method retrieves the count messages before this message. For the first call, this should be set to -1 if there are no messages.

count

The number of messages to retrieve.

callback

The callback for retrieving historical messages, ordered chronologically from newest to oldest.


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int baseMessageId, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)

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 ID 22, the corresponding parameters would be: getHistoryMessages(conversationType, targetId, RC:ImgMsg, 22, 10, true, resultCallback).

Parameters

conversationType

The type of conversation Conversation.ConversationType

targetId

The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.

objectName

The message type identifier. Examples include RC:TxtMsg, RC:ImgMsg, RC:VcMsg, etc. value

baseMessageId

The starting message ID.

count

The number of messages to retrieve.

direction

The direction of the messages relative to the baseMessageId Using the specified baseMessageId as the starting point, messages earlier than baseMessageId are FRONT, and those later are BEHIND.

callback

The callback for retrieving historical messages, ordered from newest to oldest.


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, List<String> objectNames, long timestamp, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)

Retrieves a list of messages in the conversation that meet the specified criteria.

For example: To get the 10 previous image and text messages before the message with messageId 22, the objectNames should 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).

Parameters

conversationType

The type of conversation Conversation.ConversationType

targetId

The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.

objectNames

A List of message type identifiers. For example, a List containing RC:TxtMsg, RC:ImgMsg, RC:VcMsg, etc.

timestamp

The timestamp of the current message.

count

The number of messages to retrieve.

direction

The direction of the messages to retrieve relative to the current message RongCommonDefine.GetMessageDirection Using the current message as the starting point, messages earlier than the current message are FRONT, otherwise they are BEHIND.

callback

The callback for retrieving historical messages, ordered from newest to oldest.


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)

Retrieves the latest message entities of a specified type, before a specified message, and within a specified count in a conversation.

Parameters

conversationType

The type of conversation. Refer to .

targetId

The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.

oldestMessageId

The ID of the last message. Retrieves the `count` messages before this message. Set to -1 for the first call when no messages exist.

count

The number of messages to retrieve.

callback

The callback for retrieving historical messages, ordered from newest to oldest.


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, long sentTime, int before, int after, RongIMClient.ResultCallback<List<Message>> resultCallback)

Searches for messages before and after the specified message in a conversation.

The returned message list will include the specified message. The messages are ordered from newest to oldest.

Parameters

conversationType

The specified conversation type.

targetId

The specified conversation ID.

sentTime

The send time of the specified message, which cannot be 0.

before

The number of messages before the specified message.

after

The number of messages after the specified message.

resultCallback

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 510 - 500, sorted in descending order by message ID.


@Deprecated()
public abstract List<Message> getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count)

Deprecated

Retrieves a list of messages that meet the specified criteria in the conversation.

Return

Historical messages, ordered from newest to oldest.

Deprecated

This method is deprecated. It is recommended to use getHistoryMessages or getHistoryMessages asynchronous methods instead.

Parameters

conversationType

The type of conversation Conversation.ConversationType.

targetId

The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.

oldestMessageId

The ID of the last message. Retrieves the `count` messages before this message. Set to `-1` for the first call when no messages are available.

count

The number of messages to retrieve.


@Deprecated()
public abstract List<Message> getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count)

Deprecated

Retrieves a list of messages in the conversation that meet the specified criteria.

Return

A list of historical messages, sorted from newest to oldest.

Deprecated

This method is deprecated. It is recommended to use getHistoryMessages or getHistoryMessages asynchronous methods instead.

Parameters

conversationType

The type of conversation Conversation.ConversationType.

targetId

The ID of the conversation. Depending on the conversationType, this could be a user ID, discussion group ID, or group ID.

objectName

The message type identifier.

oldestMessageId

The ID of the last message. Retrieves `count` messages before this message. Set to `-1` for the first call when no messages exist.

count

The number of messages to retrieve.