---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration
title: Initial configuration
updated_at: 2026-06-04T11:09:41.412Z
---

> 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


# Initial configuration

Initialize and configure the Chat SDK before building your chat app.

## Prerequisites

1. [Sign in](https://admin.pubnub.com/#/login) or [create an account](https://admin.pubnub.com/#/register) on the Admin Portal.
2. [Create an app](https://www.youtube.com/watch?v=ou5RMN1LQ1Y&t=19s&ab_channel=PubNub) to get your **Publish Key** and **Subscribe Key**.

:::warning Limit of 3 keysets for Free tier accounts
Effective February 3, 2025, all [Free tier](https://www.pubnub.com/pricing/) accounts are limited to a maximum of three keysets. If your account exceeds this limit, you must delete existing keysets to create new ones.
:::

A new app receives demo keys automatically. You can create multiple keysets per app. Use separate keysets for production and test environments.

:::warning Required keyset settings
Enable these features on your keyset in the Admin Portal:
* **App Context** - Store user and channel data
* **Presence** - Track online/offline status
* **Message Persistence** - Store message history
:::

## Download the SDK

Download the SDK from any of the following sources:

### Get the source code

You can download the source code from [GitHub](https://github.com/pubnub/swift-chat-sdk).

### Use Xcode

1. Create or open your project inside Xcode.
2. Navigate to **File -> Add Package Dependencies**.
3. Search for `https://github.com/pubnub/swift-chat-sdk`.
4. From the **Dependency Rule** drop-down list, select the `Up to Next Major Version` rule, and click **Add Package**.

## Initialize PubNub

Use the `ChatImpl` class to create a Chat SDK instance. Two parameters are required: `subscribeKey` and `userId`.

Optional parameters configure features like typing indicators, presence tracking, push notifications, and rate limiting.

To initialize PubNub with the Chat SDK:

1. Import the PubNubSwiftChatSDK and PubNubSDK modules inside your Swift source files: 1import PubNubSDK2import PubNubSwiftChatSDK
2. Create a ChatImpl object, which takes the following parameters: ConfigurationDescriptionpubNubConfigurationAn instance of the PubNub account configuration. You must provide at least the subscribeKey and userId to connect to PubNub.chatConfigurationAn instance of chat-specific configuration required to implement advanced features, like typing indicator, user offline/online presence, push notifications, or client-side limiting that prevents spamming. Strong referenceWe recommend that you create a strong reference to the ChatImpl object to avoid problems caused by garbage collection or lost state.
3. Call the initialize() method on your ChatImpl object. Refer to Basic usage for an example.

##### Chat SDK-specific configuration

```swift
public struct ChatConfiguration {
  public var logLevel: LogLevel
  public var typingTimeout: Int
  public var storeUserActivityInterval: Int
  public var storeUserActivityTimestamps: Bool
  public var pushNotificationsConfig: PushNotificationsConfig
  public var rateLimitFactor: Int
  public var rateLimitPerChannel: [ChannelType: Int64]
  public var customPayloads: CustomPayloads?
  public var emitReadReceiptEvents: [ChannelType: Bool]
  public var syncMutedUsers: Bool

  public init(
    logLevel: LogLevel = .off,
    typingTimeout: Int = 5,
    storeUserActivityInterval: Int = 600,
    storeUserActivityTimestamps: Bool = false,
    pushNotificationsConfig: PushNotificationsConfig = .init(),
    rateLimitFactor: Int = 2,
    rateLimitPerChannel: [ChannelType: Int64] = ChannelType.allCases.reduce(into: [ChannelType: Int64]()) { res, type in res[type] = 0 },
    customPayloads: CustomPayloads? = nil,
    syncMutedUsers: Bool = false,
    emitReadReceiptEvents: [ChannelType: Bool] = [.direct: true, .group: true, .public: false, .unknown: true]
  )
}

public struct PushNotificationsConfig {
  public var sendPushes: Bool
  public var deviceToken: String?
  public var deviceGateway: PubNub.PushService
  public var apnsTopic: String?
  public var apnsEnvironment: PubNub.PushEnvironment
  
  public init(
    sendPushes: Bool = false,
    deviceToken: String? = nil,
    deviceGateway: PubNub.PushService = .fcm,
    apnsTopic: String? = nil,
    apnsEnvironment: PubNub.PushEnvironment = .development
  )
}
```

### Input parameters

| Parameter | Description |
| --- | --- |
| `pubNubConfiguration`Type: `PubNubConfiguration` | Mandatory PubNub account configuration. |
| `> publishKey`Type: String | Specifies the key used to publish messages on a channel. |
| `> subscribeKey`Type: String | Specifies the key used to subscribe to a channel. |
| `> userId`Type: String | [Unique User ID](https://www.pubnub.com/docs/general/setup/users-and-devices) that becomes your app's current user. It's a string of up to 92 characters that identifies a single client (end user, device, or server) that connects to PubNub. Based on User ID, PubNub calculates pricing for your apps' usage. User ID should be persisted and remain unchanged. If you don't set `userId`, you won't be able to connect to PubNub. |
| `chatConfiguration`Type: [ChatConfiguration](#chatconfiguration) | [ChatConfiguration](#chatconfiguration) contains chat app configuration settings, such as `saveDebugLog` or `typingTimeout` that you provide when initializing your chat app with the [initialize()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration#initialize-pubnub) method. You can later directly access these properties, like: `chat.storeUserActivityInterval`. |

#### ChatConfiguration

| Parameter | Feature | Description |
| --- | --- | --- |
| `logLevel`Type: `LogLevel`Default: `.off` | [Error logging](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/error-logging) | Specifies if any Chat SDK-related errors should be logged. It's disabled by default. Available options include: `off`, `error`, `warn`, `info`, `debug`, and `verbose`. |
| `typingTimeout`Type: `Int`Default: `5` | [Typing Indicator](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/typing-indicator) | Specifies the default timeout after which the [typing indicator](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/typing-indicator) automatically stops when no typing signals are received. The default and maximum value is set to 5 seconds. |
| `storeUserActivityInterval`Type: `Int`Default: `600` | [User's last online activity, global presence](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence#global-presence) | Specifies how often the user global presence in the app should be updated. Requires `storeUserActivityTimestamps` to be set to `true`. The default value is set to 600 seconds, and the minimum possible value is 60 seconds. If you try to set it to a lower value, you'll get the `storeUserActivityInterval must be at least 60000ms` error. |
| `storeUserActivityTimestamps`Type: `Bool`Default: `false` | [User's last online activity, global presence](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence#global-presence) | Specifies if you want to track the user's [global presence](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence#global-presence) in your chat app. The user's activity is tracked through the [lastActiveTimestamp](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/user) parameter on the `User` object. |
| `pushNotificationsConfig`Type: `PushNotificationsConfig`Default: n/a | [Push Notifications](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications) | List of parameters you must set if you want to enable sending/receiving [mobile push notifications](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications) for phone devices, either through Apple Push Notification service (APNS) or Firebase Cloud Messaging (FCM). |
| `> sendPushes`Type: `Bool`Default: `false` | as above | The main option for enabling sending notifications. It must be set to `true` if you want a particular client (whether a mobile device, web browser, or server) to send push notifications to mobile devices. These push notifications are messages with a provider-specific payload that the Chat SDK automatically attaches to every message. Chat SDK includes a [default payload setup](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications) for `deviceGateway` in every message sent to the registered channels. This is the only required option to enable if you want to send push notifications to Android devices. For iOS devices, you also have to configure `apnsTopic`. |
| `> deviceToken`Type: `String`Default: n/a | as above | Option for receiving notifications on iOS and Android devices. A device token refers to the unique identifier assigned to a specific mobile device by a platform's push notification service. It targets and delivers push notifications to the intended app on that specific device. Suppose you don't set this option and try to run [channel registration-related methods](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications#register-selected-push-channels). In that case, you'll get the `Device Token has to be defined in Chat pushNotifications config` error. Refer to the official [Apple](https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns#2942135) and [Google](https://firebase.google.com/docs/cloud-messaging/ios/client) docs to learn how to obtain a device token for the APNs and FCM services. |
| `> deviceGateway`Type: `PubNub.PushService`Default: `fcm` | as above | Option for receiving push notifications on Android (`fcm`) or iOS (`apns` or `apns2`) devices. These are the available types: apns - Apple Push Notification service, apns2 - Apple Push Notification service v2, fcm - Firebase Cloud Messaging |
| `> apnsTopic`Type: `String`Default: n/a | as above | An Apple specific-option for sending and receiving notifications. This string is a [bundle ID](https://help.apple.com/xcode/mac/current/#/deve70ea917b) that you must define yourself for your iOS app so that Apple could [enable push notifications](https://help.apple.com/xcode/mac/current/#/devdfd3d04a1) for it in APNs. The string takes the following format: `com.domainname.applicationname`. Apple combines that ID with your Team ID (generated by Apple) and creates an [App ID](https://help.apple.com/xcode/mac/current/#/dev618af4e67) for your application. To send pushes from an iOS device, you must also set `sendPushes` to `true`. To receive pushes on an iOS device, you must also set `deviceGateway` to `apns2`, define `deviceToken`, and `apnsEnvironment`. Suppose you don't configure `apnsTopic`, but set `deviceGateway` to `apns2`. In that case, you'll get the `apnsTopic has to be defined when deviceGateway is set to apns2` error and Chat SDK won't attach the `apns` payload to messages. |
| `> apnsEnvironment`Type: `PubNub.PushEnvironment`Default: `development` | as above | Option for receiving notifications on iOS devices. When registering for push notifications, this option specifies whether to use the development (`development`) or production (`production`) [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment). |
| `rateLimitFactor`Type: `Int`Default: `2` | [Client-side rate limiting](#client-side-rate-limiting) | The so-called ["exponential backoff"](https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/) which multiplicatively decreases the rate at which messages are published on channels. It's bound to the `rateLimitPerChannel` parameter and is meant to prevent message spamming caused by excessive retries. The default value of `2` means that if you set `rateLimitPerChannel` for direct channels to 1 second and try to send three messages on such a channel type within the span of one second, the second message will be published one second after the first one (just like the `rateLimitPerChannel` value states), but the third one will be published two seconds after the second one, meaning the publishing time is multiplied by `2`. |
| `rateLimitPerChannel`Type: `[ChannelType: Int64]`Default: n/a | [Client-side rate limiting](#client-side-rate-limiting) | Client-side limit that states the rate at which messages can be published on a given channel type. Its purpose is to prevent message spamming in your chat app. This parameter takes an object with these three parameters: `direct`, `group`, and `public`. |
| `> direct`Type: `Int`Default: `0` (no limit) | as above | Rate set on all direct (1:1) channels at which messages can be published. |
| `> group`Type: `Int`Default: `0` (no limit) | as above | Rate set on all group channels at which messages can be published. |
| `> public`Type: `Int`Default: `0` (no limit) | as above | Rate set on all public channels at which messages can be published. |
| `> unknown`Type: `Int`Default: `0` (no limit) | as above | Rate set on all channels created using the [Swift SDK](https://www.pubnub.com/docs/sdks/swift/api-reference/objects#set-channel-metadata) instead of Swift Chat SDK. |
| `customPayloads`Type: `CustomPayloads`Default: n/a | [Send and receive messages](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/send-receive) | Property that lets you define your custom message payload to be sent and/or received by Chat SDK on one or all channels, whenever it differs from the default `message.text` Chat SDK payload. It also lets you configure your own message actions whenever a message is edited or deleted. For examples, check [Custom payload](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration#custom-payload). |
| `> getMessagePublishBody`Type: Function that takes three parameters: EventContent.TextMessageContent object, String representing a channel ID, DefaultGetMessagePublishBody representing a default handlerDefault: n/a | as above | Function that lets Chat SDK send your custom payload structure. It defines the structure of your own message payload's body (of `any` type) that you're sending through PubNub. Expand the [Message-related types](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/message#properties) section for more details on the required `TextMessageContent` structure. Define `getMessageResponseBody` whenever you use `getMessagePublishBody`. |
| `> getMessageResponseBody`Type: Function that takes three parameters: JSONCodable representing the message response, String representing a channel ID, DefaultGetMessageResponseBody representing a default handlerDefault: n/a | as above | Function that lets Chat SDK receive your custom payload structure. Use it to let Chat SDK translate your custom message payload into the default Chat SDK message format (defined in `EventContent.TextMessageContent`). Expand the [Message-related types](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/message#properties) section for more details on the required `EventContent.TextMessageContent` structure. Define `getMessagePublishBody` whenever you use `getMessageResponseBody`. |
| `> editMessageActionName`Type: `String`Default: n/a | as above | A type of action you want to be added to your [Message](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/message) object whenever a published message is edited, like `"changed"` or `"modified"`. The default message reaction used by Chat SDK is `"edited"`. Expand the [Message-related types](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/message#properties) section for more details. |
| `> deleteMessageActionName`Type: `String`Default: n/a | as above | A type of action you want to be added to your [Message](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/message) object whenever a published message is deleted, like `"removed"`. The default message reaction used by Chat SDK is `"deleted"`. Expand the [Message-related types](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/message#properties) section for more details. |
| `emitReadReceiptEvents`Type: `[ChannelType: Bool]`Default: `[.direct: true, .group: true, .public: false, .unknown: true]` | [Read receipts](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/read-receipts) | Controls whether read receipt events are emitted per channel type when calling `setLastReadMessage()`, `setLastReadMessageTimetoken()`, or `markAllMessagesAsRead()`. Set a channel type to `false` to suppress read receipt signals on that type. |
| `syncMutedUsers`Type: `Bool`Default: `false` | [User moderation](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/moderation-user) | Whether the mute list is synchronized across sessions and devices. For more information, refer to [Sync muted users](#sync-muted-users). |

#### Sync muted users

The `syncMutedUsers` parameter determines whether the [mute list](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/moderation-user) is synchronized across sessions and devices using a specific App Context User object.

When set to `false`, the mute list modifications are stored only for the duration of the current session. Once the session ends, the mute list is cleared.

When set to `true`, the client-side mute list is automatically saved and retrieved from App Context, ensuring that the muted user list persists beyond the current session. App Context uses a designated channel where all mute list data is sent: `PN_PRIV.$currentUserId.mute1`.

:::warning Mute list and Access Manager
If you use Access Manager within your chat app and `syncMutedUsers` is enabled, you must grant the Swift Chat SDK user the following permissions:
* `read` permission to the `PN_PRIV.$currentUserId.mute1` channel.
* `update`, `delete`, and `get` permissions for the `PN_PRIV.$currentUserId.mute1` user.
Make sure to change `$currentUserId` to the user ID of the chat user that will use the mute list functionality.
:::

#### Additional configuration options

Since the Swift Chat SDK heavily relies on the latest [Swift SDK](https://www.pubnub.com/docs/sdks/swift) for all the underlying methods, when initializing the Swift Chat SDK client, you can also make use of all optional parameters that come with the Swift SDK.

For example, you can decide how long the server will consider the client alive for presence (`presenceTimeout`) or how often the client will announce itself to the server (`heartbeatInterval`).

For the whole list of all such inherited optional parameters which you can define when initializing the Chat SDK instance, check the [Swift SDK configuration document](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#methods).

### Sample code

#### Required setup

Use this basic example to initialize the client setting only the required parameters.

```swift
// An example of how to initialize the top-level ChatImpl object
// Create PubNub configuration
let pubNubConfiguration = PubNubConfiguration(
  publishKey: "your-publish-key",
  subscribeKey: "your-subscribe-key",
  userId: "your-user-id"
  // Add other required parameters
)
  
// Create Chat configuration
let chatConfiguration = ChatConfiguration(
  // Fill in the necessary parameters for ChatConfiguration
)
  
// Important: store the ChatImpl in a property to maintain a strong reference.
// If it is not retained, it will be deallocated
let chat = ChatImpl(
  chatConfiguration: chatConfiguration,
  pubNubConfiguration: pubNubConfiguration
)
  
try await chat.initialize()
```

#### Typing indicator timeout

Create the PubNub Chat SDK and set the default typing indicator timeout value to three seconds.

```swift
// An example of how to initialize the top-level ChatImpl object
// Create PubNub configuration
let pubNubConfiguration = PubNubConfiguration(
  publishKey: "your-publish-key",
  subscribeKey: "your-subscribe-key",
  userId: "your-user-id"
  // Add other required parameters
)
  
// Create Chat configuration
let chatConfiguration = ChatConfiguration(
  typingTimeout: 3
)
  
// Important: store the ChatImpl in a property to maintain a strong reference.
// If it is not retained, it will be deallocated
let chat = ChatImpl(
  chatConfiguration: chatConfiguration,
  pubNubConfiguration: pubNubConfiguration
)
  
try await chat.initialize()
```

#### Client-side rate limiting

Initialize the PubNub Chat SDK and set the hard limit for message publishing on public channels to three seconds. If there are more publish retries within this limit, each next retry limit should be multiplied by `3`.

```swift
// An example of how to initialize the top-level ChatImpl object
// Create PubNub configuration
let pubNubConfiguration = PubNubConfiguration(
  publishKey: "your-publish-key",
  subscribeKey: "your-subscribe-key",
  userId: "your-user-id"
  // Add other required parameters
)
  
// Create Chat configuration
let chatConfiguration = ChatConfiguration(
  rateLimitFactor: 3,
  rateLimitPerChannel: [
    .public: Int64(3 * 1000) // 3 seconds converted to milliseconds
  ]
)
  
// Important: store the ChatImpl in a property to maintain a strong reference.
// If it is not retained, it will be deallocated
let chat = ChatImpl(
  chatConfiguration: chatConfiguration,
  pubNubConfiguration: pubNubConfiguration
)
  
try await chat.initialize()
```

#### Custom payload

When [initializing Chat SDK](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration#initialize-pubnub), you can pass your custom message payload structure using the [customPayloads](#input-parameters) object and related properties. This will let Chat SDK correctly interpret your app's messages when sending and receiving them.

##### Define custom payload for all channels

Let's say your app doesn't follow the default `message.text` message body structure imposed by Chat SDK but instead uses the `my.custom.payload.structure.text` structure.

To successfully communicate with PubNub and send/receive messages through Chat SDK, pass your custom payload to all channels. Additionally, define your custom action names to be added to messages when they're edited or deleted.

```swift
// Define custom payloads
let customPayloads = CustomPayloads(
  getMessagePublishBody: { content, _, _ in
    return [
      "custom": [
        "payload": [
          "text": content.text
        ]
        // Optionally also save files as ["files": content.files]
      ]
    ]
  },
  getMessageResponseBody: { json, _, _ in
    guard
      let custom = try? json.decode([String: AnyJSON].self),
      let payload = custom["payload"],
      let text = payload["text"]?.stringOptional
    else {
      fatalError("Message cannot be parsed")
    }
      
    // Optionally parse files
    return EventContent.TextMessageContent(text: text)
  }
)
  
// Create a configuration that you can later provide to the ChatImpl constructor
let chatConfiguration = ChatConfiguration(
  customPayloads: customPayloads
)
```

##### Define custom payload for one channel

Let's say your app doesn't follow the default `message.text` message body structure imposed by Chat SDK for `support-channel` but instead uses the `my.custom.payload.structure.text` structure to communicate with PubNub.

Pass your custom payload to `support-channel` to successfully communicate with PubNub and send/receive messages through Chat SDK. Additionally, define your custom action names to be added to messages when they're edited or deleted.

The code sets up a PubNub chat instance with specific handlers for processing message payloads differently based on the channel.

```swift
// Define custom payloads
let customPayloads = CustomPayloads(
  getMessagePublishBody: { content, channelId, defaultHandler in
    if channelId == "support-channel" {
      return [
        "my": [
          "custom": [
            "payload": [
              "structure": content.text
            ]
          ]
        ],
        // Optional parameter
        "files": content.files as Any,
      ] as [String: Any]
    }
    // Default Chat SDK message body structure for other channels
    return defaultHandler(content)
  },
  getMessageResponseBody: { json, channelId, defaultHandler in
    if channelId == "support-channel" {
      guard
        let custom = json.codableValue.dictionaryOptional?["my"] as? [String: Any],
        let payload = custom["custom"] as? [String: Any],
        let structure = payload["payload"] as? [String: Any],
        let text = structure["structure"] as? String
      else {
        fatalError("Message cannot be parsed")
      }
      return EventContent.TextMessageContent(text: text)
    }
    // Default Chat SDK message body structure for other channels
    return defaultHandler(json)
  },
  // Override the default edit action name
  editMessageActionName: "updated",
  // Override the default delete action name
  deleteMessageActionName: "removed"
)
```

## Listen for connection status

`addConnectionStatusListener()` registers a callback that fires whenever the SDK's connection state changes. Use it to show connection indicators or react to network interruptions.

### Method signature

```swift
chat.addConnectionStatusListener(
    _ listener: @escaping (ConnectionStatus) -> Void
) -> AutoCloseable
```

#### Input

| Parameter | Description |
| --- | --- |
| `_ listener` *Type: `(ConnectionStatus) -> Void`Default: n/a | Closure called whenever the connection state changes. Available `ConnectionStatus` values: `connected`, `reconnecting`, `disconnected`, `connectionError`. |

#### Output

| Parameter | Description |
| --- | --- |
| `AutoCloseable` | An object you must retain. When released or closed, the listener is removed. |

### Sample code

Show an in-app indicator when the connection is lost and clear it once reconnected.

```swift
// Important: Keep a strong reference to the returned "AutoCloseable" object as long as you want
// to receive updates. If the "AutoCloseable" is deallocated, the stream will be cancelled,
// and no further items will be produced. You can also stop receiving updates manually
// by calling the "close()" method on the "AutoCloseable" object.
autoCloseable = chat.addConnectionStatusListener { status in
  switch status {
  case .online:
    print("Connected to PubNub")
  case .offline:
    print("Disconnected from PubNub")
  case .connectionError(let error):
    print("Connection error: \(error)")
  }
}
```

## Connection lifecycle

Use these methods to manage the Chat SDK's active subscriptions and release SDK resources.

### Disconnect subscriptions

`disconnectSubscriptions()` pauses all active subscriptions without releasing SDK resources. Use it to temporarily stop receiving real-time updates, such as when the app moves to the background.

#### Method signature

```swift
chat.disconnectSubscriptions()
```

#### Input

This method takes no input parameters.

#### Output

This method returns no output data.

#### Sample code

```swift
// Pause all subscriptions when the app enters the background.
chat.disconnectSubscriptions()
```

### Reconnect subscriptions

`reconnectSubscriptions()` re-establishes all subscriptions that were previously disconnected. Use it to resume real-time updates after calling `disconnectSubscriptions()` or recovering from a network interruption.

#### Method signature

```swift
chat.reconnectSubscriptions()
```

#### Input

This method takes no input parameters.

#### Output

This method returns no output data.

#### Sample code

```swift
// Resume all subscriptions when the app returns to the foreground.
chat.reconnectSubscriptions()
```

### Destroy

`destroy()` releases all SDK resources and cancels all active subscriptions. Call it when the user logs out or when your app no longer needs the Chat SDK instance. After calling `destroy()`, the `ChatImpl` instance is no longer usable.

#### Method signature

```swift
chat.destroy()
```

#### Input

This method takes no input parameters.

#### Output

This method returns no output data.

#### Sample code

```swift
// Release all Chat SDK resources on logout.
chat.destroy()
```

## Next steps

After initialization, you can:

* Create [channels](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/create) and [users](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/create)
* Add features like [messaging](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/send-receive), [typing indicators](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/typing-indicator), and [presence](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence)