---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/leave
title: Leave channels
updated_at: 2026-06-12T11:23:12.627Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Leave channels

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) for your keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

Remove a user's channel membership with `leave()`.

## Method signature

This method has the following signature:

```swift
channel.leave() async throws
```

### Input

This method doesn't take any parameters.

### Output

| Parameter | Description |
| --- | --- |
| `Void` | Indicates that the operation completed successfully with no additional data. |

## Sample code

:::tip 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.

```swift
// Assumes a "ChatImpl" reference named "chat"
Task {
  if let channel = try await chat.getChannel(channelId: "support") {
    try await channel.leave()
  } else {
    debugPrint("Channel not found")
  }
}
```