searchLocalMessages
Feature Introduction
Description
Search local messages.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<SearchResult> searchLocalMessages({
String? conversationID,
List<String> keywordList = const [],
int keywordListMatchType = 0,
List<String> senderUserIDList = const [],
List<int> messageTypeList = const [],
int searchTimePosition = 0,
int searchTimePeriod = 0,
int pageIndex = 1,
int count = 40,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
conversationID | String | No | Search by conversation. If it's a global search, pass null |
keywordList | List<String> | Yes | List of search keywords, currently supports searching for one keyword only |
keywordListMatchType | int | No | Keyword matching mode, 1 means "and", 2 means "or", not used at the moment |
senderUserIDList | List<String> | No | List of specified sender uids. Not used currently |
messageTypeList | List<int> | Yes | List of message types |
searchTimePosition | int | Yes | Starting point of the search. Default is 0, meaning search starts now. UTC timestamp in seconds |
searchTimePeriod | int | Yes | Time range from the starting point, in seconds. Default is 0, meaning no time limit |
pageIndex | int | Yes | Current page number |
count | int | Yes | Number of items per page |
Return Result
Name | Type | Description |
---|---|---|
~ | SearchResult | Successful return |
SearchResult
Field Name | Field Type | Description |
---|---|---|
totalCount | int | Total number of messages found |
searchResultItems | List<SearchResultItems> | Search results returned by the searchXXX method |
Code Sample
SearchResult result = await OpenIM.iMManager.messageManager.searchLocalMessages();
// todo
Function Prototype
- (void)searchLocalMessages:(OIMSearchParam *)param
onSuccess:(nullable OIMMessageSearchCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
conversationID | NSString | No | Conversation ID. If null, it's a global search |
keywordList | NSArray<NSString *> | Yes | List of search keywords, currently supports searching for one keyword only |
keywordListMatchType | NSInteger | No | Keyword matching mode, 1 means "and", 2 means "or", not used at the moment |
senderUserIDList | NSArray<NSString *> | No | List of specified sender uids. Not used currently |
messageTypeList | NSArray<MessageContentType> | Yes | List of message types |
searchTimePosition | NSInteger | No | Starting point of the search. Default is 0, meaning search starts now. UTC timestamp in seconds |
searchTimePeriod | NSInteger | No | Time range from the starting point, in seconds. Default is 0, meaning no time limit |
pageIndex | NSInteger | No | Current page number, starts from 1. Invalid when conversationID is null, i.e., in global search |
count | NSInteger | No | Number of items per page. Invalid when conversationID is null, i.e., in global search |
Return Result
Name | Type | Description |
---|---|---|
onSuccess | OIMSearchResultInfo | Successful return |
onFailure | OIMFailureCallback | Failed return |
OIMSearchResultInfo
Field Name | Field Type | Description |
---|---|---|
totalCount | NSInteger | Total number of messages found |
searchResultItems | NSArray< 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) {
}];
Function Prototype
type SearchMessageResult = {
totalCount: number;
searchResultItems: SearchMessageResultItem[];
};
IMSDK.searchLocalMessages({
conversationID?: string;
keywordList: string[];
keywordListMatchType?: number;
senderUserIDList?: string[];
messageTypeList: MessageType[];
searchTimePosition: number;
searchTimePeriod: number;
pageIndex: number;
count: number;
}, operationID?: string): Promise<WsResponse<SearchMessageResult>>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
conversationID | string | No | Search based on a conversation. If it's a global search, pass an empty string. |
keywordList | string[] | Yes | Search keyword list, currently only supports one keyword search. |
keywordListMatchType | number | No | Keyword matching mode, 1 means "AND", 2 means "OR", currently unused. |
senderUserIDList | string[] | No | Specifies the list of message sending userIDs, currently unused. |
messageTypeList | MessageType[] | Yes | List of message types. |
searchTimePosition | number | Yes | The starting point of the search. By default, 0 means to start the search from now. UTC timestamp, in seconds. |
searchTimePeriod | number | Yes | The time range from the starting point, in seconds. By default, 0 means no time limit, 24x60x60 means the past day. |
pageIndex | number | Yes | Current page number. |
count | number | Yes | Number of items per page. |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<SearchMessageResult>> | Success callback |
Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.searchLocalMessages({
conversationID: '',
keywordList: ['keyword'],
keywordListMatchType: 0,
senderUserIDList: [],
messageTypeList: [101],
searchTimePosition: 0,
searchTimePeriod: 0,
pageIndex: 1,
count: 20,
})
.then(({ data }) => {
// On successful call
})
.catch(({ errCode, errMsg }) => {
// On failed call
});
Function Prototype
type SearchMessageResult = {
totalCount: number;
searchResultItems: SearchMessageResultItem[];
};
IMSDK.asyncApi('searchLocalMessages', operationID: string, {
conversationID?: string;
keywordList: string[];
keywordListMatchType?: number;
senderUserIDList?: string[];
messageTypeList: MessageType[];
searchTimePosition: number;
searchTimePeriod: number;
pageIndex: number;
count: number;
}): Promise<SearchMessageResult>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem localization, keep unique, recommend using the current time and a random number. |
conversationID | string | No | Search based on a conversation. If it's a global search, pass an empty string. |
keywordList | string[] | Yes | Search keyword list, currently only supports one keyword search. |
keywordListMatchType | number | No | Keyword matching mode, 1 means "AND", 2 means "OR", currently unused. |
senderUserIDList | string[] | No | Specifies the list of message sending userIDs, currently unused. |
messageTypeList | MessageType[] | Yes | List of message types. |
searchTimePosition | number | Yes | The starting point of the search. By default, 0 means to start the search from now. UTC timestamp, in seconds. |
searchTimePeriod | number | Yes | The time range from the starting point, in seconds. By default, 0 means no time limit, 24x60x60 means the past day. |
pageIndex | number | Yes | Current page number. |
count | number | Yes | Number of items per page. |
Return Results
The function is made into a Promise via the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to handle success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<SearchMessageResult> | Success callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('searchLocalMessages', IMSDK.uuid(), {
conversationID: '',
keywordList: ['keyword'],
keywordListMatchType: 0,
senderUserIDList: [],
messageTypeList: [101],
searchTimePosition: 0,
searchTimePeriod: 0,
pageIndex: 1,
count: 20,
})
.then((data) => {
// On successful call
})
.catch(({ errCode, errMsg }) => {
// On failed call
});
Function Prototype
type SearchMessageResult = {
totalCount: number;
searchResultItems: SearchMessageResultItem[];
};
OpenIMSDKRN.searchLocalMessages( {
conversationID?: string,
keywordList: string[],
keywordListMatchType?: number,
senderUserIDList?: string[],
messageTypeList: MessageType[],
searchTimePosition: number,
searchTimePeriod: number,
pageIndex: number,
count: number,
}, operationID: string): Promise<SearchMessageResult>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem localization, keep unique, recommend using the current time and a random number. |
conversationID | string | No | Search based on a conversation. If it's a global search, pass an empty string. |
keywordList | string[] | Yes | Search keyword list, currently only supports one keyword search. |
keywordListMatchType | number | No | Keyword matching mode, 1 means "AND", 2 means "OR", currently unused. |
senderUserIDList | string[] | No | Specifies the list of message sending userIDs, currently unused. |
messageTypeList | MessageType[] | Yes | List of message types. |
searchTimePosition | number | Yes | The starting point of the search. By default, 0 means to start the search from now. UTC timestamp, in seconds. |
searchTimePeriod | number | Yes | The time range from the starting point, in seconds. By default, 0 means no time limit, 24x60x60 means the past day. |
pageIndex | number | Yes | Current page number. |
count | number | Yes | Number of items per page. |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<SearchMessageResult> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.searchLocalMessages({
conversationID: '',
keywordList: ['keyword'],
keywordListMatchType: 0,
senderUserIDList: [],
messageTypeList: [101],
searchTimePosition: 0,
searchTimePeriod: 0,
pageIndex: 1,
count: 20,
}, 'operationID')
.then((data) => {
// On successful call
})
.catch(({ errCode, errMsg }) => {
// On failed call
});
Function Prototype
public static void SearchLocalMessages(OnBase<SearchMessageResult> cb, SearchMessagesParams searchParam)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase< SearchMessageResult> | Yes | Callback |
searchParam | SearchMessagesParams | Yes | Search Setting |
Return Result
SearchMessageResult
Field Name | Field Type | Description |
---|---|---|
TotalCount | int | Total number of messages found |
SearchResultItems | List<SearchResultItems> | Search results |
Code Example
IMSDK.SearchLocalMessages((res,errCode,errMsg)=>{
},new SearchMessagesParams(){
});