getSpecifiedFriendsInfo
Feature Introduction
Note
(1) Retrieve specific friend's nickname, avatar, and remarks. (2) This function fetches data from the APP locally. A maximum of 10,000 entries is recommended per fetch.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<FriendInfo>> getFriendsInfo({
required List<String> userIDList,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
userIDList | List<String> | Yes | List of user IDs |
Return Value
Parameter Name | Data Type | Description |
---|---|---|
~ | List< FriendInfo > | Successful return |
Code Example
List<FriendInfo> list = await OpenIM.iMManager.friendshipManager.getFriendsInfo(userIDList: []);
// todo
Function Prototype
- (void)getSpecifiedFriendsInfo:(NSArray <NSString *> *)usersID
onSuccess:(nullable OIMFriendsInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
usersID | NSArray <NSString *> | Yes | List of user IDs |
Return Value
Parameter Name | Data Type | Description |
---|---|---|
onSuccess | NSArray< OIMFriendInfo * > | Successful return |
onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager getSpecifiedFriendsInfo:@[]
onSuccess:^(NSArray<OIMFriendInfo *> * _Nullable userInfos) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getFriendsInfo(OnBase<List<UserInfo>> base, List<String> uidList, Boolean filterBlack)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
uidList | List<String> | Yes | List of user IDs |
filterBlack | Boolean | No | if true, the return value will not be include blacklist users. |
Code Example
OpenIMClient.getInstance().friendshipManager.getFriendsInfo(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
}
}, uidList, filterBlack);
Function Prototype
IMSDK.getSpecifiedFriendsInfo({
friendUserIDList: string[];
filterBlack?: boolean;
}, operationID?: string): Promise<WsResponse<FriendUserItem[]>>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
friendUserIDList | string[] | Yes | User ID list |
filterBlack | boolean | No | Whether to filter out the blacklist |
operationID | string | No | Operation ID, which is used to locate the problem. Keep it unique. You are advised to use the current time and random number |
Return Value
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<FriendUserItem[]>> | List of friend information |
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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
const userIDList = ['userID1', 'userID2'];
IMSDK.getSpecifiedFriendsInfo({
friendUserIDList: userIDList
})
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('getSpecifiedFriendsInfo', operationID: string, {
friendUserIDList: string[];
filterBlack?: boolean;
}): Promise<FriendUserItem[]>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
friendUserIDList | string[] | Yes | User ID list |
filterBlack | boolean | No | Whether to filter out the blacklist |
operationID | string | Yes | Operation ID, which is used to locate the problem. Keep it unique. You are advised to use the current time and random number |
Return Value
The function is Promise-wrapped through the
openim-uniapp-polyfill
package. Usethen
andcatch
to handle successful and failed callbacks.
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<FriendUserItem[]>> | List of friend information |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
const userIDList = ['userID1', 'userID2'];
IMSDK.asyncApi('getSpecifiedFriendsInfo', IMSDK.uuid(), {
friendUserIDList: userIDList
})
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.getSpecifiedFriendsInfo({
friendUserIDList: string[];
filterBlack?: boolean;
}, operationID: string): Promise<FriendUserItem[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
friendUserIDList | string[] | Yes | User ID list |
filterBlack | boolean | No | Whether to filter out the blacklist |
operationID | string | Yes | Operation ID, which is used to locate the problem. Keep it unique. You are advised to use the current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<FriendUserItem[]>> | List of friend information |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
const userIDList = ['userID1', 'userID2'];
OpenIMSDKRN.getSpecifiedFriendsInfo({
friendUserIDList: userIDList
}, 'operationID')
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void GetSpecifiedFriendsInfo(OnBase<List<FriendInfo>> cb, string[] userIdList,bool filterBlack)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<List<FriendInfo>> | Yes | Callback |
userIdList | string[] | Yes | User ID Array |
filterBlack | Boolean | No | if true, the return value will not be include blacklist users. |
Code Example
IMSDK.GetSpecifiedFriendsInfo((list,errCode,errMsg)=>{
},{"userid"},true);