Skip to main content

User Information Model

UserInfo is the user information object provided by the SDK.

PropertyTypeDescriptionVersion
userIdStringUser ID.1.0.0
userNameStringUser name.1.0.0
portraitStringUser avatar URL.1.0.0
extraMap<String, String>Extension fields.1.0.0
updatedTimelongUpdate timestamp.1.0.0

Get User Information

//API definition

/**
* get user information
* @param userId user ID
* @return user information
*/
UserInfo getUserInfo(String userId);
//Example code
UserInfo userInfo = JIM.getInstance().getUserInfoManager().getUserInfo("userId");

Get User Information in Batches

//API definition

/**
* get user information in batches
* @param userIdList user ID list
* @return user information list
*/
List<UserInfo> getUserInfoList(List<String> userIdList);
//Example code
List<String> userIdList = new ArrayList<>();
userIdList.add("userId1");
userIdList.add("userId2");
List<UserInfo> userInfoList = JIM.getInstance().getUserInfoManager().getUserInfoList(userIdList);

Fetch the Latest User Information from the Server

//API definition
/**
* get the latest user information from the server
* @param userId user ID
* @param callback result callback
*/
void fetchUserInfo(String userId, JIMConst.IResultCallback<UserInfo> callback);

//Example code
JIM.getInstance().getUserInfoManager().fetchUserInfo("userId", new JIMConst.IResultCallback<UserInfo>() {
@Override
public void onSuccess(UserInfo userInfo) {

}

@Override
public void onError(int errorCode) {

}
});