SDKsReact Native
Load message history
OpenIM React Native SDK guide for load message history.
Use getAdvancedHistoryMessageList() to page through older messages in a conversation. Pass an empty string for startClientMsgID on the first page, then pass the clientMsgID of the oldest loaded message.
const page = await OpenIMSDK.getAdvancedHistoryMessageList({
conversationID,
startClientMsgID: oldestMessage?.clientMsgID ?? '',
count: 30,
viewType: ViewType.History,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Conversation whose history is loaded. |
startClientMsgID | string | Yes | Pagination anchor; pass an empty string for the first page. |
count | number | Yes | Number of messages to load. |
viewType | ViewType | Yes | Use ViewType.History when browsing message history. |
Return value
The call returns AdvancedGetMessageResult:
| Field | Type | Description |
|---|---|---|
messageList | MessageItem[] | Messages on the current page. |
isEnd | boolean | Whether the older boundary has been reached. |
errCode | number | Status code for this history request. |
errMsg | string | Description corresponding to errCode. |
Deduplicate messages by clientMsgID before adding messageList to the conversation.
Was this page helpful?