getHistoryMessages

public abstract void getHistoryMessages(ConversationType conversationType, String targetId, String channelId, String objectName, int oldestMessageId, int count, IRongCoreCallback.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 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

conversationType

The type of conversation . Chatrooms are not supported.

targetId

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

channelId

The business identifier of the conversation to which the message belongs.

objectName

The type identifier of the message.

oldestMessageId

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.

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, String channelId, String objectName, int baseMessageId, 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 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

conversationType

The type of conversation . Chatrooms are not supported.

targetId

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

channelId

The business identifier for the conversation to which the message belongs.

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 . The specified baseMessageId is used 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 channelId, List<String> objectNames, long timestamp, 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 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

conversationType

The type of conversation , chatrooms are not supported.

targetId

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

channelId

The business identifier of the conversation to which the message belongs.

objectNames

A List of message type identifiers. For example, 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 io.rong.imlib.RongCommonDefine.GetMessageDirection Using the current message as the starting point, messages before 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, String channelId, IRongCoreCallback.ResultCallback<List<Message>> callback)

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

conversationType

The type of conversation. Chatrooms are not supported. Refer to Conversation.ConversationType.

targetId

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

channelId

The business identifier of the conversation to which the message belongs.

oldestMessageId

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

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, String channelId, long sentTime, int before, int after, IRongCoreCallback.ResultCallback<List<Message>> resultCallback)

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

conversationType

The specified conversation type.

targetId

The specified conversation ID.

channelId

The business identifier of the conversation to which the message belongs.

sentTime

The sending 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

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.