Skip to main content

searchLocalMessages

Feature Introduction

Description

Search local messages.

Function Prototype


- (void)searchLocalMessages:(OIMSearchParam *)param
onSuccess:(nullable OIMMessageSearchCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

Input Parameters

Parameter NameParameter TypeMandatoryDescription
conversationIDNSStringNoConversation ID. If null, it's a global search
keywordListNSArray<NSString *>YesList of search keywords, currently supports searching for one keyword only
keywordListMatchTypeNSIntegerNoKeyword matching mode, 1 means "and", 2 means "or", not used at the moment
senderUserIDListNSArray<NSString *>NoList of specified sender uids. Not used currently
messageTypeListNSArray<MessageContentType>YesList of message types
searchTimePositionNSIntegerNoStarting point of the search. Default is 0, meaning search starts now. UTC timestamp in seconds
searchTimePeriodNSIntegerNoTime range from the starting point, in seconds. Default is 0, meaning no time limit
pageIndexNSIntegerNoCurrent page number, starts from 1. Invalid when conversationID is null, i.e., in global search
countNSIntegerNoNumber of items per page. Invalid when conversationID is null, i.e., in global search

Return Result

NameTypeDescription
onSuccessOIMSearchResultInfoSuccessful return
onFailureOIMFailureCallbackFailed return

OIMSearchResultInfo

Field NameField TypeDescription
totalCountNSIntegerTotal number of messages found
searchResultItemsNSArray< OIMSearchResultItemInfo *>Search results

Code Sample


OIMSearchParam *param = [OIMSearchParam new];
param.conversationID = @"";
param.keywordList = @[];

[OIMManager.manager searchLocalMessages:param
onSuccess:^(OIMSearchResultInfo * _Nullable result) {

} onFailure:^(NSInteger code, NSString * _Nullable msg) {

}];