Browse SDKs · React Native
SDKsReact Native

Load message history

OpenIM React Native SDK guide for load message history.

Copy

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

ParameterTypeRequiredDescription
conversationIDstringYesConversation whose history is loaded.
startClientMsgIDstringYesPagination anchor; pass an empty string for the first page.
countnumberYesNumber of messages to load.
viewTypeViewTypeYesUse ViewType.History when browsing message history.

Return value

The call returns AdvancedGetMessageResult:

FieldTypeDescription
messageListMessageItem[]Messages on the current page.
isEndbooleanWhether the older boundary has been reached.
errCodenumberStatus code for this history request.
errMsgstringDescription corresponding to errCode.

Deduplicate messages by clientMsgID before adding messageList to the conversation.