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 users in a channel

You can retrieve a list of participants who are currently online and receiving all messages from an open channel using the createParticipantListQuery() method. To retrieve a list of members in a group channel, call the members property.

Open channel

class CustomViewController: ViewController {
    var channel: OpenChannel?
    var query: ParticipantListQuery?

    func createQuery() {
        // There should be one single instance per channel.
        self.query = channel?.createParticipantListQuery()
    }

    func loadNextPage() {
        self.query?.loadNextPage(completionHandler: { messages, error in
            guard error == nil else {
                // Handle error.
                return
            }
        })
    }
}

Group channel

let members = channel.members

Members of a group channel are automatically updated when a user is online. But when a user is disconnected from the Sendbird server and then reconnected, you should call the refresh(completionHandler:) method to update their channels with the latest information. See the refresh all data related to a group channel section for the sample code.