getFriendList
Feature Introduction
Description
Retrieve all of one's friends in a single call.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<FriendInfo>> getFriendList({String? operationID, bool filterBlack = false})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filterBlack | bool | No | Whether to filter out the blacklist |
operationID | String | No | Operation ID, used for problem location, unique, recommended to use current time and random number |
Return Values
Parameter Name | Parameter Type | Description |
---|---|---|
~ | List< FriendInfo * > | Successful Return |
Code Example
List<FriendInfo> list = await OpenIM.iMManager.friendshipManager.getFriendList();
// todo
Function Prototype
- (void)getFriendListWithFilterBlack:(BOOL)filterBlack
onSuccess:(nullable OIMFriendInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filterBlack | boolean | No | Whether to filter out the blacklist |
operationID | string | No | Operation ID, used for problem location, unique, recommended to use current time and random number |
Return Values
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | NSArray< OIMFriendInfo * > | Successful Return |
onFailure | OIMFailureCallback | Failure Return |
Code Example
[OIMManager.manager getFriendListWithFilterBlack: NO,
onSuccess:^(NSArray<OIMFriendInfo *> * _Nullable userInfos) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getFriendList(OnBase<List<UserInfo>> base, Boolean filterBlack)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filterBlack | Boolean | No | if true, the return value will not be include blacklist users. |
Return Values
Parameter Name | Parameter Type | Description |
---|---|---|
data | List<UserInfo> | Success |
Code Example
OpenIMClient.getInstance().friendshipManager.getFriendList(new OnBase<List<UserInfo>>() {
@Override
public void onError(int code, String error) {
// todo: request error
}
@Override
public void onSuccess(List<UserInfo> data) {
// todo: request success
}
}, filterBlack);
Function Prototype
IMSDK.getFriendList(filterBlack?: boolean, operationID?: string): Promise<WsResponse<FriendUserItem[]>>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filterBlack | boolean | No | Whether to filter out the blacklist |
operationID | string | No | Operation ID, used for problem location, unique, recommended to use current time and random number |
Return Values
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<FriendUserItem[]>> | List of friend info |
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 { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.getFriendList()
.then(({ data }) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
IMSDK.asyncApi('getFriendList', operationID: string, filterBlack: boolean): Promise<FriendUserItem[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filterBlack | boolean | Yes | Whether to filter out the blacklist |
operationID | string | Yes | Operation ID for troubleshooting, recommended unique timestamp |
Return Values
Utilizing the
openim-uniapp-polyfill
package to make the function Promise-based. Usethen
andcatch
to handle successful and failed callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<FriendUserItem[]> | List of friend info |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getFriendList', IMSDK.uuid(), false)
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
OpenIMSDKRN.getFriendList(filterBlack: boolean, operationID: string): Promise<FriendUserItem[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filterBlack | boolean | Yes | Whether to filter out the blacklist |
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<FriendUserItem[]> | List of friend info |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getFriendList(false, 'operationID')
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
public static void GetFriendList(OnBase<FriendInfo> cb,bool filterBlack)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<List<FriendInfo>> | Yes | Callback |
filterBlack | bool | No | Whether to filter out the blacklist |
Code Example
IMSDK.GetFriendList((list,errCode,errMsg)=>{
},true);