Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
User
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Retrieve a list of blocked users

By using the BlockedUserListQuery's loadNextPage(completionHandler:) method, you can retrieve a list of all or specific blocked users in your Sendbird application. The method returns a list of User objects that contain information about the blocked users.

class CustomViewController: ViewController {
    var query: BlockedUserListQuery?
    
    // ...
    
    func createQuery() {
        // Retrieve all blocked users.
        self.query = SendbirdChat.createBlockedUserListQuery()
    }
    
    func loadNextPage() {
        self.query?.loadNextPage { users, error in
            guard error == nil else {
                // Handle error.
                return
            }

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

With BlockedUserListQueryParams's userIdsFilter, you can retrieve a list of blocked users with the specified user IDs.

class CustomViewController: ViewController {
    var query: BlockedUserListQuery?
    
    // ...
    
    func createQuery() {
        // Retrieve specific blocked users using userIdsFilter.
        self.query = SendbirdChat.createBlockedUserListQuery { params in
            //params is the BlockedUserListQueryParams object.
            params.userIdsFilter = ["John", "Daniel", "Jeff"]
        }
    }
    
    func loadNextPage() {
        self.query?.loadNextPage { users, error in
            guard error == nil else {
                // Handle error.
                return
            }

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