SDKsiOSEnterprise
Load message context
Retrieve messages before and after a specified message with OpenIM iOS SDK.
After locating a message, use it as the anchor for retrieving surrounding context:
OIMFetchSurroundingMessagesReq *request = [OIMFetchSurroundingMessagesReq new];
request.startMessage = locatedMessage;
request.viewType = OIMFetchSurroundingHistoryViewTypeSearch;
request.before = 20;
request.after = 20;
[[OIMManager manager] fetchSurroundingMessages:request
onSuccess:^(NSArray<OIMMessageInfo *> *messages) {
[self replaceContext:messages ?: @[]];
}
onFailure:nil];Choose viewType for the search or quote scenario. The result may contain fewer than before + after + 1 messages. Identify the anchor and deduplicate by clientMsgID; do not depend on a fixed array position. To retrieve the anchor first, see Find messages by ID.
Was this page helpful?