searchGroups
Feature Introduction
Description
Search for joined groups using keywords.
Note
(1) At least one search domain must be specified; (2) The relationship between multiple domains is "or".
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<GroupInfo>> searchGroups({
List<String> keywordList = const [],
bool isSearchGroupID = false,
bool isSearchGroupName = false,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
keywordList | List<String> | Yes | Search keywords. Currently only supports a single keyword search and cannot be empty. |
isSearchGroupID | bool | Yes | Whether to search by group ID. |
isSearchGroupName | bool | Yes | Whether to search by group name. |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
~ | List<GroupInfo> | Success return |
Code Example
List<GroupInfo> list = await OpenIM.iMManager.groupManager.searchGroups(
keywordList: ['ok'],
isSearchGroupID: true,
isSearchGroupName: true,
);
// todo
Function Prototype
- (void)searchGroups:(OIMSearchGroupParam *)searchParam
onSuccess:(nullable OIMGroupsInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
OIMSearchGroupParam.keywordList | NSArray< NSString * | Yes | Search keywords. Currently only supports a single keyword search and cannot be empty. |
OIMSearchGroupParam.isSearchGroupID | BOOL | No | Whether to search by group ID. Note: Both cannot be false at the same time. Default is false. |
OIMSearchGroupParam.isSearchGroupName | BOOL | No | Whether to search by group name. Default is false. |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | NSArray< OIMGroupInfo * | Success return |
onFailure | OIMFailureCallback | Failure return |
Code Example
OIMSearchGroupParam *param = [OIMSearchGroupParam new];
param.isSearchGroupName = YES;
param.keywordList = @[];
[OIMManager.manager searchGroups:param
onSuccess:^(NSArray<OIMGroupInfo *> * _Nullable groupsInfo) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void searchGroups(OnBase<List<GroupInfo>> callBack, List<String> keywordList, boolean isSearchGroupID, boolean isSearchGroupName)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase<List<GroupInfo>> | Yes | Callback interface |
keywordList | List<String> | Yes | Keywords |
isSearchGroupID | Boolean | Yes | Search by group ID |
isSearchGroupName | Boolean | Yes | Search by group nickname |
Return Results
Code Example
OpenIMClient.getInstance().groupManager.searchGroups(new OnBase<List<GroupInfo>>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(List<GroupInfo> data) {
}
}, keywordList, isSearchGroupID, isSearchGroupName);
Function Prototype
IMSDK.searchGroups({
keywordList: string[];
isSearchGroupID: boolean;
isSearchGroupName: boolean;
}, operationID?: string): Promise<WsResponse<GroupItem[]>>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
keywordList | string[] | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
isSearchGroupID | boolean | Yes | Whether to search by keyword for group ID |
isSearchGroupName | boolean | Yes | Whether to search by keyword for group name |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<GroupItem[]>> | List of found group information |
Promise.catch() | Promise<WsResponse> | Callback for a failed call |
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.searchGroups({
keywordList: ['nickname'];
isSearchGroupID: false,
isSearchGroupName: true,
})
.then(({data}) => {
// Success callback
})
.catch(({ errCode, errMsg }) => {
// Error callback
});
Function Prototype
IMSDK.asyncApi('searchGroups', operationID: string, {
keywordList: string[];
isSearchGroupID: boolean;
isSearchGroupName: boolean;
}): Promise<GroupItem[]>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem tracking, should be unique, it's recommended to use the current time and a random number |
keywordList | string[] | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
isSearchGroupID | boolean | Yes | Whether to search by keyword for group ID |
isSearchGroupName | boolean | Yes | Whether to search by keyword for group name |
Return Results
The
openim-uniapp-polyfill
package makes the function return a Promise. When calling, you need to usethen
andcatch
to determine and handle successful and failed callbacks.
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<GroupItem[]> | List of found group information |
Promise.catch() | Promise<CatchResponse> | Callback for a failed call |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('searchGroups', IMSDK.uuid(), {
keywordList: ['nickname'];
isSearchUserID: false,
isSearchNickname: true,
isSearchRemark: true,
})
.then((data) => {
// Success callback
})
.catch(({ errCode, errMsg }) => {
// Error callback
});
Function Prototype
OpenIMSDKRN.searchGroups({
keywordList: string[];
isSearchGroupID: boolean;
isSearchGroupName: boolean;
}, operationID: string): Promise<GroupItem[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
keywordList | string[] | Yes | Search keyword. Currently, only supports one keyword and cannot be empty. |
isSearchGroupID | boolean | Yes | Whether to search by keyword for group ID |
isSearchGroupName | boolean | Yes | Whether to search by keyword for group name |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<GroupItem[]> | List of found group information |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.searchGroups({
keywordList: ['nickname'];
isSearchUserID: false,
isSearchNickname: true,
isSearchRemark: true,
}, 'operationID')
.then((data) => {
// Success callback
})
.catch(({ errCode, errMsg }) => {
// Error callback
});
Function Prototype
public static void SearchGroups(OnBase<List<GroupInfo>> cb, SearchGroupsParam searchParam)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<List<GroupInfo>> | Yes | Callback |
searchParam | SearchGroupsParam | Yes | Search keyword. Currently, only supports one keyword and cannot be empty. |
Return Result
Code Example
IMSDK.SearchGroups((list,errCode,errMsg)=>{
},new SearchGroupsParam(){
KeywordList = {},
IsSearchGroupID = true,
IsSearchGroupName = false
} );