Browse SDKs · WASM
SDKsWASM

Update your profile

Update the signed-in user’s nickname, avatar, and extension data.

Copy

setSelfInfo() updates the signed-in user's basic display profile. Pass only the nickname, faceURL, or ex fields that need to change.

Parameters

ParameterTypeRequiredDescription
nicknamestringNoNew nickname.
faceURLstringNoNew avatar URL.
exstringNoNew extension string. It completely replaces the previous value.

Pass at least one profile field that actually needs to be updated.

await openimsdk.setSelfInfo({
  nickname: nickname.trim(),
  faceURL,
  ex: mergedExtra,
});

ex is a complete string; the SDK does not merge JSON automatically. If several application modules share it, read the current value first and merge each module's namespace before updating it.

setSelfInfo() also carries account-level policy fields, but they should not be saved together with ordinary profile data. See Set global message reception and Set friend request permissions for the corresponding operations.

A successful Promise means that the update request has completed, not that the profile event has arrived. Reconcile the final profile through OnSelfInfoUpdated or getSelfUserInfo().

Listen for changes to the current user profile

This page owns the complete OnSelfInfoUpdated listener. The event carries the updated SelfUserInfo; replace the current user snapshot with it.

import { SdkEvent } from '@openim/wasm-client-sdk';

const handleSelfInfoUpdated = ({ data }) => setCurrentUser(data);

openimsdk.on(SdkEvent.OnSelfInfoUpdated, handleSelfInfoUpdated);

function removeProfileListener() {
  openimsdk.off(SdkEvent.OnSelfInfoUpdated, handleSelfInfoUpdated);
}

Call removeProfileListener() when signing out, switching accounts, or destroying the user state layer.