Browse SDKs · iOS
SDKsiOS

Load message history

Retrieve conversation history by page with OpenIM iOS SDK.

Copy

Use this selector to establish the first snapshot when opening a chat page. When loading more history, pass the clientMsgID of the current boundary message.

OIMGetAdvancedHistoryMessageListParam *param = [OIMGetAdvancedHistoryMessageListParam new];
param.conversationID = conversationID;
param.startClientMsgID = startClientMsgID;
param.count = 20;
param.viewType = OIMGetHistoryViewTypeHistory;

[[OIMManager manager] getAdvancedHistoryMessageList:param
    onSuccess:^(OIMGetAdvancedHistoryMessageListInfo *result) {
        [self prependMessages:result.messageList ?: @[]];
    }
    onFailure:nil];

startClientMsgID may be nil for the first page. The success result is also nullable and must be checked before use. When present, use messageList and isEnd to update pagination state. The query does not trigger the new-message delegate. Deduplicate merged results by conversationID:clientMsgID.