getUsersInfoWithCache
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<UserInfo>> getUsersInfoWithCache(
List<String> userIDs, {
String? groupID,
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<UserInfo > | Successful callback |
onError | Function | Error callback |
Code Example
await OpenIM.iMManager.userManager.getUsersInfoWithCache([], '');
// todo
Function Prototype
- (void)getUsersInfoWithCache:(NSArray<NSString *> *)userIDs
groupID:(NSString * _Nullable)groupID
onSuccess:(nullable OIMUsersInfoCallback)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 | OIMUserInfo | 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 getUsersInfoWithCache(OnBase<List<UserInfo>> callBack, List<String> uidList,String groupID)
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase<List<UserInfo>> | Yes | Callback |
uidList | List<String> | Yes | List of user IDs |
groupID | String | No | Group ID |
Return Value
Code Example
OpenIMClient.getInstance().userInfoManager.getUsersInfoWithCache(new OnBase<List<UserInfo>>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(List<UserInfo> data) {
}
},uidList,groupId);
Function Prototype
IMSDK.getUsersInfoWithCache({
userIDList: string[];
groupID?: string;
}, operationID?: string): Promise<WsResponse<FullUserItem[]>>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
userIDList | string[] | Yes | List of user IDs |
groupID | string | No | Group ID |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<FullUserItem[]>> | List of retrieved user information |
Promise.catch() | Promise<WsResponse> | Callback for failed call |
Code Sample
import { getSDK } from 'open-im-sdk-wasm';
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.getUsersInfoWithCache({
userIDList,
groupID: 'groupID',
})
.then(({ data }) => {
// data: List of retrieved user information
})
.catch(({ errCode, errMsg }) => {
// Call failure
});
Function Prototype
IMSDK.asyncApi('getUsersInfoWithCache', operationID: string, {
userIDList: string[];
groupID?: string;
}): Promise<FullUserInfo[]>
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 |
groupID | string | No | Group ID |
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<FullUserInfo[]> | 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('getUsersInfoWithCache', IMSDK.uuid(), {
userIDList,
groupID: 'groupID',
})
.then((data) => {
// data: List of retrieved user information
})
.catch(({ errCode, errMsg }) => {
// Call failure
});
Function Prototype
OpenIMSDKRN.getUsersInfoWithCache( {
userIDList: string[];
groupID?: string;
}, operationID: string): Promise<FullUserInfo[]>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
userIDList | string[] | Yes | List of user IDs |
groupID | string | No | Group ID |
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<FullUserInfo[]> | 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.getUsersInfoWithCache({
userIDList,
groupID: 'groupID',
}, 'operationID')
.then((data) => {
// data: List of retrieved user information
})
.catch(({ errCode, errMsg }) => {
// Call failure
});
Function Prototype
public static void GetUsersInfoWithCache(OnFullUserInfoWithCacheList cb, string[] userIds, string groupId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnFullUserInfoWithCacheList | 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);