Skip to main content
Version: 4.x.x

Remove Participant - iOS

When hosting a live stream, it's essential for the host to have the capability to remove a participant from the live stream. This can be useful in various scenarios where a participant is causing disturbance, behaving inappropriately, or is not following the guidelines. This guide focuses on this very aspect of removing a participant from the live stream.

VideoSDK provides three ways to do so:

  1. Using SDK
  2. Using VideoSDK Dashboard
  3. Using Rest API

1. Using SDK​

remove()​

The remove() method allows for the removal of a participant during an ongoing session. This can be helpful when moderation is required in a particular live stream.

To remove a participant, call remove() on their Participant object. It is async throws, so call it with try await inside a Task. It throws a VideoSDKError if the call fails, for example ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED when you call it before joining the live stream.

extension LiveStreamViewController {
//Button when tapped will remove the participant with given participantID
@IBAction func removeParticipant(_ sender: Any) {
let participantID = "ABCD"

guard let participant = room?.participants[participantID] else {
return
}
Task {
do {
try await participant.remove()
} catch {
print("Could not remove the participant: \(error)")
}
}
}
}

Events associated with remove()​

The following callbacks are received when a participant is removed from the live stream.

2. Using VideoSDK Dashboard​

  • For removing a participant using the VideoSDK Dashboard, navigate to the session page on VideoSDK Dashboard. Select the specific session, and from the list of participants, choose the participant you wish to remove. Utilize the provided options to remove the selected participant from the session.

3. Using Rest API​

  • You can also remove a particular participant from the live stream using the REST API.
  • To employ this method, you need the sessionId of the live stream and the participantId of the individual you intend to remove.

API Reference​

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord