Update the current user profile
Update the nickname, avatar, or custom extensions for the authenticated user using setSelfInfo().
Update basic profile attributes for the authenticated user, including nickname, avatar URL, and custom business extension strings. Populate only the fields that require modification.
Code example
UserInfoReq request = new UserInfoReq();
request.setNickname(displayName.trim());
request.setFaceURL(avatarURL);
request.setEx(extra);
OpenIMClient.getInstance().userInfoManager.setSelfInfo(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Profile updated successfully
}
@Override
public void onError(int code, String error) {
// Handle error
}
},
request
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
request | UserInfoReq | Yes | Request payload holding fields to update. |
Profile attributes
| Field | Type | Description |
|---|---|---|
nickname | String | New display nickname to set. |
faceURL | String | New avatar image URL. |
ex | String | Custom business metadata string formatted according to application specifications. |
Friend request permissions and account-wide DND rules are managed independently; see Set friend request permissions and Set global message reception.
Return value
The successful callback indicates that the server persisted the profile updates. The changes synchronize across all devices authenticated with the user account.
State changes after the call
After updating the profile, the SDK dispatches the update via OnUserListener. Locate the cached profile by userID, merge modified properties, and refresh the UI:
@Override
public void onSelfInfoUpdated(UserInfo info) {
// Current user profile updated; merge local cache and refresh the UI
}Was this page helpful?