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.

Although globalRecvMsgOpt is also written through setSelfInfo(), it is an account-level messaging policy and should not be saved together with ordinary profile fields. See Set global message reception for its enum values and interaction with conversation-level settings.

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 { CbEvents } from '@openim/wasm-client-sdk';

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

openimsdk.on(CbEvents.OnSelfInfoUpdated, handleSelfInfoUpdated);

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

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