Browse SDKs · uni-app / uni-app x
SDKsuni-app

Get your profile

Read the OpenIM profile of the logged-in user.

Copy

After initialization, login, and connection readiness, call getSelfUserInfo() to query the current account's profile:

import {
  getSelfUserInfo,
  type OpenIMUserInfo,
} from '@/uni_modules/unix-openim-sdk'

const currentUser : OpenIMUserInfo | null = await getSelfUserInfo()
if (currentUser != null) {
  renderProfile(currentUser.nickname, currentUser.faceURL)
}

Return result

The Promise resolves directly to OpenIMUserInfo or null, without a { data } wrapper. A non-null object contains:

FieldTypeDescription
userIDstringSigned-in user's OpenIMSDK user ID and the stable identifier for this profile snapshot.
nicknamestringAccount-level nickname.
faceURLstringAccount-level avatar URL.
createTimenumber or null (optional)Time when the user record was created.
globalRecvMsgOpt Enterprisenumber or null (optional)Account-level message reception option. See Set global message reception.
attachedInfo Enterprisestring or null (optional)SDK attachment data. Parse it only according to a confirmed application contract.
exstringAccount-level extension string defined by the application.

Verify that the returned userID matches the current application account. Do not fabricate an empty user object when the result is null; use login state and redacted diagnostics to determine why a snapshot is unavailable.

This query establishes a snapshot and does not trigger a profile event. Clear it when switching accounts. See Update your profile for merging onSelfInfoUpdated and reconciling with another query.