Skip to main content

Get Participants

Retrieves the list of participants for a specific chatroom. This function allows users to fetch participant information with options for pagination and filtering.

Steps to get participants

  1. Create a GetParticipantsRequest object using GetParticipantsRequest.builder() class by passing all the required parameters.
  2. Call getParticipants() function using the instance of LMChatClient.
  3. Process the response LMResponse<GetParticipantsResponse> as per your requirement.
// object of GetParticipantsRequest
let request = GetParticipantsRequest.builder()
.chatroomId("ENTER_CHATROOM_ID")
.isChatroomSecret(false)
.page(1)
.pageSize(20)
.participantName(nil)
.build()

LMChatClient.shared.getParticipants(request: request) { response in
// response (LMResponse<GetParticipantsResponse>)
if let data = response.data {
// your function to process the response data
processParticipants(data)
} else if let error = response.error {
// your function to process error
handleError(error)
}
}

Models

GetParticipantsRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
isChatroomSecretBoolIndicates if the chatroom is secret
chatroomIdStringID of the chatroom
participantNameStringName to filter participants (if any)✔️
pageIntPage number for pagination (default is 1)
pageSizeIntNumber of participants per page (default is 20)

GetParticipantsResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
canEditParticipantBoolIndicates if the current user can edit participants✔️
participants[Member]Array of participant members✔️
totalParticipantsCountIntTotal number of participants in the chatroom✔️