getUsersInfo
Introduction
Get the info or profile of users.
Specified the self User to load the data of self.
This method supports batch requests, but have better no more than 100, to avoid the rejection of the IM server, as the request package exceed 1M.
Also you can query the users, regardless if friends, with this method.
What should I do if the user profile obtained is not the latest?
There are two types of user profile updates in the enhanced SDK:
Friend's profile: When the profile of a friend is updated, the backend will send a system notification to the SDK, so the profile will be updated in real time.
Non-friend user's profile: When the profile of a non-friend user is updated, the backend cannot send a system notification to the SDK; therefore, the profile cannot be updated in real time. To avoid sending a network request to the backend every time the user profile is obtained, the SDK adds the caching logic and allows a user to pull the profile from the backend every ten minutes.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
userIDList | string[] | yes | The list of users to query. |
Returned template
V2TimValueCallback<V2TimUserFullInfo[]>
{
code : number
desc : string
data : V2TimUserFullInfo[]//The list of results.
}
Return value details
name | type | description |
---|---|---|
code | number | Request result: Error codes. 0 means success. |
desc | string | The description of the error. It will be empty if success. |
data | V2TimUserFullInfo[] | The list of results. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const userIDList = [];
const getUsersInfoRes = await TencentImSDKPlugin.v2TIMManager.getUsersInfo(
userIDList
);
if (getUsersInfoRes.code === 0) {
getUsersInfoRes.data?.forEach((element) => {
element.allowType;
element.birthday;
element.customInfo;
element.faceUrl;
element.gender;
element.level;
element.nickName;
element.role;
element.selfSignature;
element.userID;
});
}