Leave channels

Requires App Context

To set up and manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.

Use the leave() method to remove user's channel membership and unsubscribe them from receiving messages and events.

Method signature

This method has the following signature:

channel.leave() -> async throws

Input

This method doesn't take any parameters.

Output

ParameterDescription
Void
Indicates that the operation completed successfully with no additional data.

Basic usage

Sample code

The code samples in Swift Chat SDK focus on asynchronous code execution.

You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.

Leave the support channel.

// Assuming you have a reference of type "ChatImpl" named "chat"
Task {
if let channel = try await chat.getChannel(channelId: "support") {
try await channel.leave()
} else {
debugPrint("Channel not found")
}
}
Last updated on