Browse SDKs · Android
SDKsAndroid

Unsubscribe from user status

Use unsubscribeOnlineUsersStatus to cancel online-status subscriptions for specified users.

Copy

Cancel online-status subscriptions when users leave the visible range, the screen closes, or the account changes. Remove empty and duplicate IDs before making the call.

List<String> userIDs = Arrays.asList("user_a", "user_b");

OpenIMClient.getInstance().userInfoManager.unsubscribeOnlineUsersStatus(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Unsubscription succeeded.
        }

        @Override
        public void onError(int code, String error) {
            // Handle the error.
        }
    },
    userIDs
);

A successful callback means that the unsubscribe request completed.

Call Subscribe to user online status when those users need to be tracked again.