SDKsAndroid
Unsubscribe from user status
Cancel presence subscriptions for specified users to stop receiving real-time status updates.
Cancel active presence subscriptions when users scroll out of view, screens are destroyed, or accounts switch. This avoids processing extraneous status broadcast events.
Code example
List<String> userIDs = Arrays.asList("user_a", "user_b");
OpenIMClient.getInstance().userInfoManager.unsubscribeOnlineUsersStatus(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Unsubscription confirmed
}
@Override
public void onError(int code, String error) {
// Handle error
}
},
userIDs
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
userIDs | List<String> | Yes | List of target user IDs to unsubscribe from. Remove empty strings and duplicates before calling. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback confirms that the server has stopped broadcasting status transitions for the specified users to this client session. - Local cache management: Clear corresponding
userIDentries from your local presence cache according to your application requirements. - Resubscription: To resume receiving real-time presence events, call Subscribe to user status.
Was this page helpful?