getHistoryMessages

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

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

conversationType

The conversation type. Refer to .

targetId

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

oldestMessageId

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.

count

The number of messages to retrieve.

callback

The callback for retrieving historical messages, sorted in chronological order from newest to oldest.


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

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

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.

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. Use FRONT to retrieve messages older than the current message, or BEHIND for newer messages.

callback

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


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

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

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. For example, 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 messages later are BEHIND.

callback

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


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

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

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 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, IRongCoreCallback.ResultCallback<List<Message>> resultCallback)

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

conversationType

The type of the specified conversation.

targetId

The ID of the specified conversation.

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 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()
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, 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

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 identifier for the message type.

oldestMessageId

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.

count

The number of messages to retrieve.


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

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

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.