getRemoteHistoryMessages

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

Fetches historical messages from the server before a specified time.

Unlike getHistoryMessages, this interface pulls messages from the RongCloud server. After pulling messages from the server, the client performs deduplication and returns the deduplicated data. This is typically used to fetch historical messages after switching to a new device. When using this, it is recommended to first pull historical messages from the local database via getHistoryMessages. If no historical messages are found in the local database, then use this interface to fetch server historical messages, passing the timestamp of the earliest message in the local database.Note: 1. This feature requires enabling the historical message cloud storage function in the RCdeveloper console. 2. If the messages to be fetched already exist in the local database, this interface will not return any data.

Since

5.0.0

Parameters

conversationType

The type of conversation.

targetId

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

dateTime

The starting point for fetching messages. This is the sentTime getSentTime in the message; if there are no messages in the local database, you can pass 0 for the first fetch, otherwise pass the sentTime of the earliest message to fetch the latest count messages.

count

The number of messages to fetch, 0 < count <= 20.

callback

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


public abstract void getRemoteHistoryMessages(ConversationType conversationType, String targetId, RemoteHistoryMsgOption remoteHistoryMsgOption, IRongCoreCallback.ResultCallback<List<Message>> callback)

Fetches remote history messages for a specified conversation.

This feature requires the message cloud storage function to be enabled in the RongCloud Developer Console.Note: Chatrooms are not supported!

Since

5.0.0

Parameters

conversationType

Specifies the conversation type. Chatrooms are not supported.

targetId

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

remoteHistoryMsgOption

Configurable parameters RemoteHistoryMsgOption

callback

Callback for retrieving history messages, ordered from newest to oldest.