SDKsReact Native
Update your profile
Update the current user profile with the OpenIM React Native SDK.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
nickname | string | No | New nickname. |
faceURL | string | No | New avatar URL. |
ex | string | No | Extended 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.
Was this page helpful?