Browse SDKs · React Native
SDKsReact Native

Update your profile

Update the current user profile with the OpenIM React Native SDK.

Copy

Call setSelfInfo() to update the signed-in account's basic display profile. Pass only the nickname, faceURL, or ex fields that should change in this request.

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

Parameter description

ParameterTypeRequiredDescription
nicknamestringNoNew nickname.
faceURLstringNoNew avatar URL.
exstringNoExtended user information.

Pass at least one profile field that should be updated.

ex is a string. You can pass a JSON string or another business-defined format for extended user information.

After the profile is updated, the OnSelfInfoUpdated event carries the updated user information.

Listen for current-user profile changes

When the user's profile changes, OnSelfInfoUpdated is emitted with the updated SelfUserInfo:

function handleSelfInfoUpdated(selfUserInfo: SelfUserInfo) {
  // ...
}

// Add the listener
OpenIMSDK.on(OpenIMEvent.OnSelfInfoUpdated, handleSelfInfoUpdated);

// Remove the listener
OpenIMSDK.off(OpenIMEvent.OnSelfInfoUpdated, handleSelfInfoUpdated);

Remove the listener when the user logs out, switches accounts, or the user state is torn down.