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
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
keyword | String | Keyword to search for |
startTime | int | Search for messages before this timestamp. Pass 0 to start searching from the latest message. |
count | int | Number of messages to return, valid range from 0 to 50 (inclusive). |
callback | IRCIMIWSearchMessagesCallback | Event 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 Value | Description |
---|---|
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
Parameter | Type | Description |
---|---|---|
code | int | Status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
keyword | String | Keyword to search for |
startTime | int | Timestamp before which to search for messages |
count | int | Number of messages to return |
messages | List<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
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
keyword | String | Keyword to search for |
startTime | int | Start time |
endTime | int | End time |
offset | int | Offset |
count | int | Number of search results to return, valid range from 0 to 50 (inclusive). |
callback | IRCIMIWSearchMessagesByTimeRangeCallback | Event 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 Value | Description |
---|---|
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
Parameter | Type | Description |
---|---|---|
code | int | Status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
keyword | String | Keyword to search for |
startTime | int | Start time |
endTime | int | End time |
offset | int | Offset |
count | int | Number of messages to return |
messages | List<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
Parameter | Type | Description |
---|---|---|
userId | String | User ID |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
startTime | int | Start time for the search. Pass 0 to start searching from the latest message. |
count | int | Number of search results to return, valid range from 0 to 50 (inclusive). |
callback | IRCIMIWSearchMessagesByUserIdCallback | Event 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 Value | Description |
---|---|
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
Parameter | Type | Description |
---|---|---|
code | int | Status code of the callback. 0 indicates success, non-zero indicates an exception. |
userId | String | User ID |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
startTime | int | Start time for the search |
count | int | Number of messages to return |
messages | List<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) {
//...
};