Browse SDKs · uni-app / uni-app x
SDKsuni-app

Load message history

OpenIM uni-app / uni-app x SDK guide for Load message history.

Copy

Use public getAdvancedHistoryMessageList() to establish the first snapshot when a chat opens. To load older records, pass the current earliest message's clientMsgID as the next cursor.

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesConversation whose history is being loaded.
startClientMsgIDstringYesPaging anchor; pass an empty string for the first page.
countnumberYesNumber of messages to request.
lastMinSeqnumber or nullNoMinimum sequence returned by the previous page.
import { getAdvancedHistoryMessageList } from '@/uni_modules/unix-openim-sdk'

const page = await getAdvancedHistoryMessageList({
  conversationID,
  startClientMsgID: oldestMessage?.clientMsgID ?? '',
  count: 30,
  lastMinSeq,
})

Return result

The Promise resolves to OpenIMAdvancedHistoryMessageListResult | null:

FieldTypeDescription
messageListOpenIMMessageItem[]Messages in this page.
lastMinSeqnumberMinimum sequence to send with the next request.
isEndbooleanWhether the history boundary in this direction was reached.
errCodenumberHistory result status code.
errMsgstringDescription associated with the status code.

Merge messageList only when errCode reports success; handle a rejected Promise through the normal error path. Scope the list by conversationID and deduplicate by clientMsgID. History queries do not emit new-message events.

Commercial getHistoryMessageList() Commercial additionally requires isReverse and supports optional viewType and lastMinSeq. Direction is a parameter, not a separate reverse-history API.