Update current user profile
Modify profile fields such as nickname, avatar, or extensions for the authenticated user with the OpenIM React Native SDK.
Update profile fields for the authenticated account. Supply only the attributes being modified:
await OpenIMSDK.setSelfInfo({
nickname: nickname.trim(),
faceURL,
ex: mergedExtra,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
nickname | string | No | New nickname for the account. |
faceURL | string | No | New public avatar image URL. |
ex | string | No | Custom business extension string. |
Supply at least one field to update. ex is a string; serialize JSON if storing structured metadata.
Return value
A resolved Promise confirms that the profile update was applied on the server.
Mutations trigger the OnSelfInfoUpdated event with the updated SelfUserInfo payload. Reconcile local state keyed by userID.
Listen for user profile changes
Register an event listener for OnSelfInfoUpdated to keep UI components in sync when profile attributes change:
const handleSelfInfoUpdated = (selfUserInfo: SelfUserInfo) => {
// Update local profile state using selfUserInfo.userID
};
// Register listener
OpenIMSDK.on(OpenIMEvent.OnSelfInfoUpdated, handleSelfInfoUpdated);
// Remove listener
OpenIMSDK.off(OpenIMEvent.OnSelfInfoUpdated, handleSelfInfoUpdated);Unregister this listener when the component unmounts, the user signs out, or accounts switch.
Was this page helpful?