User overview
Understand user profiles, account-level preferences, and online status in the UniApp SDK.
The UniApp SDK identifies users using a unique userID. The user domain manages the authenticated account's profile, public user cards for other contacts, account-wide message reception options, friend request permissions, and real-time online presence. Relationships (friends, applications, and blacklists) belong to the separate relationship domain, while group nicknames and roles reside within the group domain.
User data models
The UTS plugin exports the following primary user data structures:
| Type | Intended context | How to obtain |
|---|---|---|
OpenIMUserInfo | The currently logged-in user profile; also serves as the base structure for public cards | Get your profile, Get user profiles |
OpenIMPublicUserItem | Public profile for other application users (alias of OpenIMUserInfo) | Get user profiles |
OpenIMFriendUserItem | Friend profile including friend remarks, pinned status, and custom extension strings | Friend query APIs in the relationships domain |
OpenIMBlackUserItem | Blocked user profile stored within the current account's blacklist | Blacklist query APIs in the relationships domain |
OpenIMUserStatusItem | Aggregated online connectivity status and active client platforms for a user | Online status subscription and query APIs |
A single userID can exist simultaneously as a public user, friend contact, blacklisted user, and group member. Render stranger profiles using OpenIMPublicUserItem; render contact rosters using OpenIMFriendUserItem; render group rosters using OpenIMGroupMemberItem; and display conversation headers using showName from the conversation object. Do not overwrite fields across distinct domains.
User profile APIs
- Get user profiles: Batch query public profile records for other users by
userID. - Get your profile: Retrieve nickname, avatar URL, extension data, and global message reception options for the active session.
- Update your profile: Update nickname, avatar URL, or custom extension attributes for the authenticated user.
- Set global message reception: Configure account-level notification and reception behaviors.
- Set friend request permissions: Choose how your account responds to incoming friend requests.
Online status APIs
- Subscribe to online status: Subscribe to presence updates for targeted users and monitor status events.
- Get subscribed user status: Query current presence snapshots for actively subscribed users.
- Unsubscribe from online status: Stop tracking presence for users no longer visible in the UI.
Online presence indicates whether a user maintains an active WebSocket session with OpenIMServer; it does not indicate whether they are viewing the app, a specific conversation, or a particular message. For typing indicators or business presence (such as "in a meeting"), use dedicated business signals rather than inferring state from WebSocket connectivity.
State synchronization principles
Load baseline snapshots via query APIs when initializing screens, then merge incoming updates through domain events. Merge current user profiles by matching userID. When online status events arrive with multiple OpenIMUserStatusItem records, iterate and merge each item into your state by userID.
Promise resolution, event delivery, and re-queries represent three distinct phases. After a mutation Promise resolves, update UI state via the corresponding event, or call the query API to re-calibrate immediately.
Was this page helpful?