/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Retrieve a list of blocked users

Copy link

By creating and using a BlockedUserListQuery instance, you can retrieve a list of all or specific blocked users in your Sendbird application. The next() method returns a list of User objects that contain information about the blocked users.

// Retrieve all blocked users.
val query = SendbirdChat.createBlockedUserListQuery(BlockedUserListQueryParams())
query.next { users, e ->
    if (e != null) {
        // Handle error.
    }

    // A list of blocked users is successfully retrieved.
    // Through the list parameter of the callback handler,
    // you can access the data of each blocked user from the result list
    // that the Sendbird server has passed to the callback handler.
    // ...
}

Using the userIds filter of the BlockedUserListQuery instance, you can retrieve a list of blocked users with the specified user IDs.

// Retrieve blocked users with userIds specified in the filter.
val userIds = listOf("John", "Daniel", "Jeff")
val query = SendbirdChat.createBlockedUserListQuery(
    BlockedUserListQueryParams().apply {
        userIdsFilter = userIds
    }
)
query.next { users, e ->
    if (e != null) {
        // Handle error.
    }

    // A list of matching users is successfully retrieved.
    // ...
}