searchGroups
Description
info
Search joined groups by keywords.
Note
(1) At least one search field must be specified;
(2) The relationship between multiple fields is an OR relationship.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron
- 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 | Required | Description |
|---|---|---|---|
| keywordList | List<String> | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
| isSearchGroupID | bool | Yes | Whether to search group ID by keyword |
| isSearchGroupName | bool | Yes | Whether to search group name by keyword |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| ~ | List<GroupInfo> | Success |
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 | Required | Description |
|---|---|---|---|
| OIMSearchGroupParam.keywordList | NSArray< NSString *> | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
| OIMSearchGroupParam.isSearchGroupID | BOOL | No | Whether to search group ID by keyword (Note: the two cannot both be false simultaneously), default false |
| OIMSearchGroupParam.isSearchGroupName | BOOL | No | Whether to search group name by keyword, default false |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| onSuccess | NSArray< OIMGroupInfo *> | Success |
| onFailure | OIMFailureCallback | Failure |
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 | Required | Description |
|---|---|---|---|
| callBack | OnBase<List<GroupInfo>> | Yes | Callback interface |
| keywordList | List<String> | Yes | Keywords |
| isSearchGroupID | Boolean | Yes | Search group ID |
| isSearchGroupName | Boolean | Yes | Search group nickname |
Return Result
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 | Parameter Type | Required | Description |
|---|---|---|---|
| keywordList | string[] | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
| isSearchGroupID | boolean | Yes | Whether to search group ID by keyword |
| isSearchGroupName | boolean | Yes | Whether to search group name by keyword |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<GroupItem[]>> | Searched group information list |
| 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();
IMSDK.searchGroups({
keywordList: ['nickname'];
isSearchGroupID: false,
isSearchGroupName: true,
})
.then(({data}) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
IMSDK.asyncApi('searchGroups', operationID: string, {
keywordList: string[];
isSearchGroupID: boolean;
isSearchGroupName: boolean;
}): Promise<GroupItem[]>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| keywordList | string[] | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
| isSearchGroupID | boolean | Yes | Whether to search group ID by keyword |
| isSearchGroupName | boolean | Yes | Whether to search group name by keyword |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<GroupItem[]> | Searched group information list |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('searchGroups', IMSDK.uuid(), {
keywordList: ['nickname'];
isSearchUserID: false,
isSearchNickname: true,
isSearchRemark: true,
})
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
OpenIMSDK.searchGroups({
keywordList: string[];
isSearchGroupID: boolean;
isSearchGroupName: boolean;
}, operationID?: string): Promise<GroupItem[]>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| keywordList | string[] | Yes | Search keywords, currently only supports one keyword search, cannot be empty |
| isSearchGroupID | boolean | Yes | Whether to search group ID by keyword |
| isSearchGroupName | boolean | Yes | Whether to search group name by keyword |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<GroupItem[]> | Searched group information list |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.searchGroups({
keywordList: ['nickname'];
isSearchUserID: false,
isSearchNickname: true,
isSearchRemark: true,
})
.then((data) => {
// Success
})
.catch((error) => {
// Failure
});
Function Prototype
public static void SearchGroups(OnBase<List<GroupInfo>> cb, SearchGroupsParam searchParam)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| cb | OnBase<List<GroupInfo>> | Yes | Callback |
| searchParam | SearchGroupsParam | Yes | Search parameters |
Return Result
Code Example
IMSDK.SearchGroups((list,errCode,errMsg)=>{
},new SearchGroupsParam(){
KeywordList = {},
IsSearchGroupID = true,
IsSearchGroupName = false
} );