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(
completion: ((Swift.Result<Void, Error>) -> Void)? = nil
)
Input
This method doesn't take any parameters.
Output
Type | Description |
---|---|
Void | Indicates that the operation completed successfully with no additional data. |
Basic usage
Leave the support
channel.
/// Assuming you have a "chat" instance available
/// Fetch metadata of the "support" channel
chat?.getChannel(
channelId: "support"
) {
switch $0 {
case let .success(channel):
if let channel = channel {
debugPrint("Fetched channel metadata with ID: \(channel.id)")
/// Leave the "support" channel
channel.leave {
switch $0 {
case .success:
print("Successfully left the support channel")
case .failure(let error):
show all 25 lines