getUsersInfo
Feature Description
Description
Retrieve nicknames and avatars in IM.
Note
(1) It's recommended to request a maximum of 100 at a time as a larger number might result in the backend rejecting the request due to the data packet being too large; (2) Data is primarily fetched from the server. If that fails, it is then retrieved from local cache; (3) When users use this interface to get the personal information of non-friends, the SDK will internally update this cache.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<PublicUserInfo>> getUsersInfo({
required List<String> userIDList,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
userIDs | List<String> | Yes | List of user IDs |
groupID | String | No | Group ID |
Return Value
Parameter Name | Data Type | Description |
---|---|---|
then | List< PublicUserInfo > | Successful callback |
onError | Function | Error callback |
Code Example
await OpenIM.iMManager.userManager.getUsersInfoWithCache([], '');
// todo
Function Prototype
- (void)getUsersInfo:(NSArray<NSString *> *)userIDs
onSuccess:(nullable OIMPublicUsersInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
userIDs | NSArray<NSString *> | Yes | List of user IDs |
groupID | NSString | No | Group ID |
Return Value
Parameter Name | Data Type | Description |
---|---|---|
onSuccess | OIMPublicUserInfo | Successful |
onFailure | OIMFailureCallback | Failure |
Code Example
[OIMManager.manager getUsersInfoWithCache:@[]
groupID:@""
onSuccess:^(NSArray<OIMUserInfo *> * _Nullable usersInfo) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getUsersInfo(OnBase<List<PublicUserInfo>> callBack, List<String> uidList)
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase<List<PublicUserInfo>> | Yes | Callback |
uidList | List<String> | Yes | List of user IDs |
Return Value
Code Example
OpenIMClient.getInstance().userInfoManager.getUsersInfo(new OnBase<List<PublicUserInfo>>() {
@Override
public void onError(int code, String error) {
// todo: request error
}
@Override
public void onSuccess(List<PublicUserInfo> data) {
// todo: request success
}
},uidList);
Function Prototype
IMSDK.getUsersInfo(userIDList: string[], operationID?: string): Promise<WsResponse<PublicUserItem[]>>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
userIDList | string[] | Yes | List of user IDs |
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 Results
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<PublicUserItem[]>> | List of retrieved user information |
Promise.catch() | Promise<WsResponse> | Callback for failed call |
Code Sample
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();
const userIDList = ['userID1', 'userID2'];
IMSDK.getUsersInfo(userIDList)
.then(({ data }) => {
// data: List of retrieved user information
})
.catch(({ errCode, errMsg }) => {
// Call failure
});
Function Prototype
IMSDK.asyncApi('getUsersInfo', operationID: string, userIDList: string[]): Promise<PublicUserItem[]>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem tracking, should be unique. Recommended to use current time and random number. |
userIDList | string[] | Yes | List of user IDs |
Return Results
The function is Promise-based through the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to determine and handle successful and failed callbacks.
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<PublicUserItem[]> | List of retrieved user information |
Promise.catch() | Promise<CatchResponse> | Callback for failed call |
Code Sample
import IMSDK from 'openim-uniapp-polyfill';
const userIDList = ['userID1', 'userID2'];
IMSDK.asyncApi('getUsersInfo', IMSDK.uuid(), userIDList)
.then((data) => {
// data: List of retrieved user information
})
.catch(({ errCode, errMsg }) => {
// Call failure
});
Function Prototype
OpenIMSDKRN.getUsersInfo(userIDList: string[], operationID: string): Promise<PublicUserItem[]>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
userIDList | string[] | Yes | List of user IDs |
operationID | string | Yes | Operation ID, for problem tracking, should be unique. Recommended to use current time and random number. |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<PublicUserItem[]> | List of retrieved user information |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
const userIDList = ['userID1', 'userID2'];
OpenIMSDKRN.getUsersInfo(userIDList, 'operationID')
.then((data) => {
// data: List of retrieved user information
})
.catch(({ errCode, errMsg }) => {
// Call failure
});
Function Prototype
public static void GetUsersInfo(OnBase<List<PublicUserInfo>> cb, string[] userIds, string groupId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<List<PublicUserInfo>> | Yes | Callback |
usrIds | string[] | Yes | Array of retrieved user information |
groupId | String | false | Group ID |
Return Result
Code Example
IMSDK.GetUsersInfoWithCache((list,errCode,errMsg)=>{
if(list!= null){
}else{
}
}, userIds, groupId);