Browse SDKs · Android
Platform
SDKsAndroid

Unsubscribe from user status

Cancel presence subscriptions for specified users to stop receiving real-time status updates.

Copy

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

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
userIDsList<String>YesList 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

  1. Callback confirmation: The onSuccess callback confirms that the server has stopped broadcasting status transitions for the specified users to this client session.
  2. Local cache management: Clear corresponding userID entries from your local presence cache according to your application requirements.
  3. Resubscription: To resume receiving real-time presence events, call Subscribe to user status.