Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Retrieve current user profile

Fetch the account profile and global preferences of the currently signed-in user.

Copy

Query the current user profile without passing parameters to retrieve the signed-in account's IMUser record:

Code example

import sdk, { GetSelfUserInfoResp } from '@openimsdk/imsdk';

const response: GetSelfUserInfoResp = await sdk.getSelfUserInfo();
setCurrentUser(response.user);

Return value

Returns a Promise that resolves to a GetSelfUserInfoResp object containing the user's account details:

PropertyTypeDescription
userIDstringUnique identifier of the signed-in user.
nicknamestringAccount-level nickname.
faceURLstringAvatar image URL.
exstringApplication-defined custom user metadata string.
globalRecvMsgOptGlobalRecvMsgOptGlobal default message reception preference.
addFriendPermissionAddFriendPermissionVerification rule when other users send friend requests.
createTimenumberAccount creation timestamp in Unix milliseconds.
attachedstringAdditional engine metadata; parse only under explicit backend agreements.

State changes after the call

This method returns a point-in-time snapshot and does not emit events. For listening to profile updates, see Update current user profile. Always clear cached profile data when signing out or switching accounts.