SDKsHarmonyOSEnterprise
Retrieve current user profile
Fetch the account profile and global preferences of the currently signed-in user.
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:
| Property | Type | Description |
|---|---|---|
userID | string | Unique identifier of the signed-in user. |
nickname | string | Account-level nickname. |
faceURL | string | Avatar image URL. |
ex | string | Application-defined custom user metadata string. |
globalRecvMsgOpt | GlobalRecvMsgOpt | Global default message reception preference. |
addFriendPermission | AddFriendPermission | Verification rule when other users send friend requests. |
createTime | number | Account creation timestamp in Unix milliseconds. |
attached | string | Additional 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.
Was this page helpful?