Browse SDKs · React Native
Platform
SDKsReact Native

Update current user profile

Modify profile fields such as nickname, avatar, or extensions for the authenticated user with the OpenIM React Native SDK.

Copy

Update profile fields for the authenticated account. Supply only the attributes being modified:

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

Parameters

ParameterTypeRequiredDescription
nicknamestringNoNew nickname for the account.
faceURLstringNoNew public avatar image URL.
exstringNoCustom 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.