Unsubscribe from online status
Stop receiving presence updates for targeted users.
Invoke unsubscribeUsersStatus() to stop tracking presence updates for specific users. When contacts paginate out of view, search queries change, or user views unmount, unsubscribe from those IDs promptly to keep the active subscription set bounded.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userIDs | string[] | Yes | An array of user IDs to unsubscribe from. |
Deduplicate array entries and remove empty values before calling this method.
Code example
import { unsubscribeUsersStatus } from '@/uni_modules/unix-openim-sdk'
const userIDs = ['user_a', 'user_b']
await unsubscribeUsersStatus(userIDs)
userIDs.forEach((userID) => {
presenceByUserID.delete(userID)
})Return value
The Promise resolves with a string operation confirmation upon successful deregistration. It does not return updated status payloads.
State changes after the call
A resolved Promise confirms that OpenIMServer removed the specified users from the active subscription set. The application should immediately remove those userID keys from its local tracking set and presence state without waiting for events to confirm the removal.
Unsubscribing from presence updates does not affect user profiles, friendship records, or conversation history. To resume tracking these users in the future, call Subscribe to online status.
When logging out or destroying the global presence manager, invoke off(subscription) to remove the event listener entirely. Unsubscribing individual users and tearing down the global listener are distinct operations.
Was this page helpful?