getRemoteHistoryMessages

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

Fetches historical messages before a specified time from the server.

Unlike getHistoryMessages, this interface pulls data from the RCserver. 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. It is recommended to first use getHistoryMessages to fetch historical messages from the local database. If no historical messages are found in the local database, 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 local database already contains the messages to be fetched, this interface will not return any data.

Parameters

conversationType

The conversation type.

targetId

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

dateTime

Fetches messages starting from this timestamp. Specifically, the sentTime in the message getSentTime. If there are no messages in the local database, pass 0 for the first call; 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, RongIMClient.ResultCallback<List<Message>> callback)

Fetches remote historical messages for a specified conversation.

This feature requires enabling the message cloud storage feature in the RongCloud Developer Console.Note: Chatrooms are not supported!

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.

remoteHistoryMsgOption

Configurable parameters RemoteHistoryMsgOption

callback

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