Skip to main content

Permissions & Moderation

Permissions & Moderation

In some types of calls, there's a requirement to moderate the behaviour of the participants. Examples include muting a participant, or ending the call for everyone. Those capabilities are usually reserved for the hosts of the call (users with elevated capabilities). They usually have additional moderation controls in their UI, that allow them to achieve these actions.

The StreamVideo SDK has support for such capabilities, with the usage of the Call's permissions features.

Requesting & Granting permission

This example shows how to check if you have permissions to do something and ask for permission. Let's say that you've joined an audio room and want to speak

// see if you currently have this permission.
let hasPermission = call.currentUserHasCapability(.sendAudio)

// request the host to grant you this permission.
let response = try await call.request(permissions: [.sendAudio])

Permission requests are exposed from call.state on the permissionRequests published variable.

if let request = call.state.permissionRequests.first {
// reject it

// grant it
try await call.grant(request: request)

You can also grant permissions directly using call.grantPermissions() method like the example below:

try await call.grant(permissions: [.sendAudio], for: "thrierry")

You can request the following 3 permissions: send-audio, send-video, and screenshare.

Revoking permissions

Similarly to granting permissions, the host, can also revoke permissions for any user in the call.

// revoke user's with id "tommaso", the permission to send audio
let response = try await call.revoke(permissions: [.sendAudio], for: "tommaso")

Moderation Capabilities

// block a user
try await call.blockUser(with: "tommaso")

// unblock a user
try await call.unblockUser(with: "tommaso")

// remove a member from a call
try await call.removeMembers(ids: ["tommaso"])

Alternatively you can also mute users.

// mutes all users (audio and video are true by default) other than yourself
try await call.muteAllUsers()

// mute user with id "tommaso" specifically
try await call.mute(userId: "tommaso")

Did you find this page helpful?