SDKsHarmonyOSEnterprise
Unsubscribe from user online status
Stop receiving online status notifications for specific user IDs.
When views unmount, paginated lists scroll away, or search results change, unsubscribe from unneeded user status updates to free server quota:
Code example
import sdk, { UnsubscribeUsersOnlineStatusReq } from '@openimsdk/imsdk';
const request: UnsubscribeUsersOnlineStatusReq = {
userIDs: ['user_a', 'user_b'],
};
await sdk.unsubscribeUsersOnlineStatus(request);
for (let index = 0; index < request.userIDs.length; index += 1) {
presenceByUserID.delete(request.userIDs[index]);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userIDs | string[] | Yes | List of user IDs to unsubscribe from. |
Return value
Returns a Promise that resolves to void when the unsubscription instruction is processed.
State changes after the call
Once the Promise resolves, delete the corresponding userID entries from your local presence cache; you do not need to wait for status change events. Unsubscribing specific user IDs and removing global event listeners are separate operations; for subscription workflows and listener details, see Subscribe to user online status.
Was this page helpful?