SDKsiOSEnterprise
Load message history in reverse
Retrieve history toward newer messages from an anchor with OpenIM iOS SDK.
When navigating to a specific message via search results, notifications, or reply references, invoke getAdvancedHistoryMessageListReverse:onSuccess:onFailure: on OIMManager to load newer messages chronologically forward from that anchor message:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
opts | OIMGetAdvancedHistoryMessageListParam * | Yes | Query configuration parameters object. |
Properties of OIMGetAdvancedHistoryMessageListParam
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | NSString * | Yes | Target conversation identifier. |
startClientMsgID | NSString * | Yes | Anchor message's clientMsgID. The SDK retrieves pages of newer messages starting after this message. |
count | NSInteger | Yes | Maximum number of messages to retrieve per page. |
viewType | OIMGetHistoryViewType | Yes | History query view type (typically OIMGetHistoryViewTypeHistory). |
Code example
OIMGetAdvancedHistoryMessageListParam *param = [OIMGetAdvancedHistoryMessageListParam new];
param.conversationID = conversationID;
param.startClientMsgID = anchorMessage.clientMsgID;
param.count = 20;
param.viewType = OIMGetHistoryViewTypeHistory;
[[OIMManager manager] getAdvancedHistoryMessageListReverse:param
onSuccess:^(OIMGetAdvancedHistoryMessageListInfo * _Nullable result) {
// Append retrieved newer messages to the bottom of the list
[self appendMessages:result.messageList ?: @[]];
}
onFailure:^(NSInteger code, NSString * _Nullable msg) {
// Handle retrieval failure
}];Return value
The onSuccess callback delivers an OIMGetAdvancedHistoryMessageListInfo instance containing:
messageList: Array of retrieved messages sorted in ascending chronological order (NSArray<OIMMessageInfo *> *).isEnd: Boolean indicating whether the newest message boundary in the conversation has been reached.lastMinSeq: Minimum sequence number in the current retrieved chunk.
State changes after the call
- Snapshot loading: Reverse pagination retrieves existing message snapshots on demand and does not trigger incoming message listeners.
- Scroll state coordination: Avoid mixing forward and backward pagination arbitrarily at the same scroll boundary. Deduplicate messages using
clientMsgIDscoped toconversationID. For standard backward history queries, see Load message history.
Was this page helpful?