Skip to main content

Search Messages

Search by Keyword

Search for messages in a specified conversation by keyword.

Method

Future<int> searchMessages(RCIMIWConversationType type, String targetId, String? channelId, String keyword, int startTime, int count, {IRCIMIWSearchMessagesCallback? callback});

Parameters

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
keywordStringKeyword to search for
startTimeintSearch for messages before this timestamp. Pass 0 to start searching from the latest message.
countintNumber of messages to return, valid range from 0 to 50 (inclusive).
callbackIRCIMIWSearchMessagesCallbackEvent callback. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>Status code of the operation. 0 indicates success. For detailed results, implement the callback interface. Non-zero values indicate failure, and no callback will be triggered. Refer to the error codes for details.

Code Example

IRCIMIWSearchMessagesCallback? callback = IRCIMIWSearchMessagesCallback(onSuccess: (List<RCIMIWMessage>? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.searchMessages(type, targetId, channelId, keyword, startTime, count, callback:callback);

Callback Method

  • onMessagesSearched

    Listener for the result of the interface call.

Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? keyword, int? startTime, int? count, List<RCIMIWMessage>? messages)? onMessagesSearched;

Parameter Description

ParameterTypeDescription
codeintStatus code of the callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
keywordStringKeyword to search for
startTimeintTimestamp before which to search for messages
countintNumber of messages to return
messagesList<RCIMIWMessage>List of messages found

Code Example

engine?.onMessagesSearched = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? keyword, int? startTime, int? count, List<RCIMIWMessage>? messages) {
//...
};

Search for Messages in a Specified Time Range

Method

Future<int> searchMessagesByTimeRange(RCIMIWConversationType type, String targetId, String? channelId, String keyword, int startTime, int endTime, int offset, int count, {IRCIMIWSearchMessagesByTimeRangeCallback? callback});

Parameters

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
keywordStringKeyword to search for
startTimeintStart time
endTimeintEnd time
offsetintOffset
countintNumber of search results to return, valid range from 0 to 50 (inclusive).
callbackIRCIMIWSearchMessagesByTimeRangeCallbackEvent callback. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>Status code of the operation. 0 indicates success. For detailed results, implement the callback interface. Non-zero values indicate failure, and no callback will be triggered. Refer to the error codes for details.

Code Example

IRCIMIWSearchMessagesByTimeRangeCallback? callback = IRCIMIWSearchMessagesByTimeRangeCallback(onSuccess: (List<RCIMIWMessage>? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.searchMessagesByTimeRange(type, targetId, channelId, keyword, startTime, endTime, offset, count, callback:callback);

Callback Method

  • onMessagesSearchedByTimeRange
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? keyword, int? startTime, int? endTime, int? offset, int? count, List<RCIMIWMessage>? messages)? onMessagesSearchedByTimeRange;

Parameter Description

ParameterTypeDescription
codeintStatus code of the callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
keywordStringKeyword to search for
startTimeintStart time
endTimeintEnd time
offsetintOffset
countintNumber of messages to return
messagesList<RCIMIWMessage>List of messages found

Code Example

engine?.onMessagesSearchedByTimeRange = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, String? keyword, int? startTime, int? endTime, int? offset, int? count, List<RCIMIWMessage>? messages) {
//...
};

Search for Messages in a Specified Conversation by User ID

Method

Future<int> searchMessagesByUserId(String userId, RCIMIWConversationType type, String targetId, String? channelId, int startTime, int count, {IRCIMIWSearchMessagesByUserIdCallback? callback});

Parameters

ParameterTypeDescription
userIdStringUser ID
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
startTimeintStart time for the search. Pass 0 to start searching from the latest message.
countintNumber of search results to return, valid range from 0 to 50 (inclusive).
callbackIRCIMIWSearchMessagesByUserIdCallbackEvent callback. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>Status code of the operation. 0 indicates success. For detailed results, implement the callback interface. Non-zero values indicate failure, and no callback will be triggered. Refer to the error codes for details.

Code Example

IRCIMIWSearchMessagesByUserIdCallback? callback = IRCIMIWSearchMessagesByUserIdCallback(onSuccess: (List<RCIMIWMessage>? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.searchMessagesByUserId(userId, type, targetId, channelId, startTime, count, callback:callback);

Callback Method

  • onMessagesSearchedByUserId

    Listener for the result of the interface call.

Function(int? code, String? userId, RCIMIWConversationType? type, String? targetId, String? channelId, int? startTime, int? count, List<RCIMIWMessage>? messages)? onMessagesSearchedByUserId;

Parameter Description

ParameterTypeDescription
codeintStatus code of the callback. 0 indicates success, non-zero indicates an exception.
userIdStringUser ID
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
startTimeintStart time for the search
countintNumber of messages to return
messagesList<RCIMIWMessage>List of messages found

Code Example

engine?.onMessagesSearchedByUserId = (int? code, String? userId, RCIMIWConversationType? type, String? targetId, String? channelId, int? startTime, int? count, List<RCIMIWMessage>? messages) {
//...
};