Update your profile
Update the signed-in user’s nickname, avatar, and extension data.
setSelfInfo() updates the signed-in user's basic display profile. Pass only the nickname, faceURL, or ex fields that need to change.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
nickname | string | No | New nickname. |
faceURL | string | No | New avatar URL. |
ex | string | No | New 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. To display the latest profile immediately, wait for OnSelfInfoUpdated or call getSelfUserInfo() again and use the returned data.
Listen for changes to the current user profile
This page provides the complete OnSelfInfoUpdated listener. The event carries the updated SelfUserInfo; replace the current user's profile 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.
Was this page helpful?