---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/chat
title: Chat object
updated_at: 2026-05-12T11:37:48.000Z
---

# Chat object

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

The `Chat` object is your entry point to the Chat SDK after [initialization](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md). Use the `Chat` object to create and manage channels, users, messages, memberships, and other entities.

Key capabilities:

* Create and delete channels and users
* Track user presence across channels
* Send custom events
* Access the underlying Swift SDK

## Properties

The `ChatImpl` class implements the `Chat` protocol and takes the following properties:

```swift
public final class ChatImpl {
  public let pubNub: PubNub
  public let config: ChatConfiguration
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| pubNub | PubNub | Optional |  | Initialized instance of the PubNub Swift SDK. `pubNub` lets you access any [Swift SDK](https://www.pubnub.com/docs/sdks/swift.md) method. For example, if you want to call a method available in the App Context API, you'd use [chat.pubNub.getAllUUIDMetadata()](https://www.pubnub.com/docs/sdks/swift/api-reference/objects.md#user). |
| > configuration | PubNubConfiguration | Optional |  | Mandatory PubNub configuration parameters. |
| > publishKey | String | Optional |  | Specifies the key used to publish messages on a channel. |
| > subscribeKey | String | Optional |  | Specifies the key used to subscribe to a channel. |
| > userId | String | Optional |  | [Unique User ID](https://www.pubnub.com/docs/general/setup/users-and-devices.md) 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. |
| config | ChatConfiguration | Optional |  | `ChatConfiguration` contains chat app configuration settings, such as `saveDebugLog` or `typingTimeout` that you provide when initializing your chat app with the [init()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md#initialize-pubnub) method. You can later directly access these properties, like: `chat.storeUserActivityInterval`. |

`ChatConfiguration` includes these properties:

```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 syncMutedUsers: Bool
  public var emitReadReceiptEvents: [ChannelType: Bool]
}
```

`PushNotificationsConfig` includes these properties:

```swift
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
}
```

To initialize the Swift Chat SDK, you must provide two parameters: `subscribeKey`, and `userId`, while all other settings (mentioned above) are optional. Read the [Configuration](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md) page for details.

## Methods

You can call the following methods on the `Chat` object.

Click on each method for more details.

* [createDirectConversation()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/create.md#create-direct-channel)
* [createGroupConversation()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/create.md#create-group-channel)
* [createPublicConversation()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/create.md#create-public-channel)
* [createUser()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/create.md)
* [currentUser](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/details.md#get-current-user)
* [deleteChannel()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/delete.md)
* [deleteUser()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/delete.md)
* [destroy()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md#destroy)
* [disconnectSubscriptions()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md#disconnect-subscriptions)
* [emitEvent()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/custom-events.md#create-and-send-events)
* [fetchUnreadMessagesCounts()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread.md#get-unread-messages-count-all-channels)
* [getChannel()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/details.md)
* [getChannelGroup()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/channel-groups.md#get-channel-group-reference)
* [getChannels()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/list.md)
* [getCurrentUserMentions()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/mentions.md#collect-all-user-related-mentions)
* [getEventsHistory()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/custom-events.md#get-historical-events)
* [getPushChannels()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications.md#list-all-push-channels)
* [getUser()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/details.md#get-user-details)
* [getUsers()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/list.md)
* [init()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md#initialize-pubnub)
* [isPresent()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence.md#check-users-channel-presence)
* listenForEvents() (deprecated — use entity-specific methods such as `onMessageReceived()`, `onTypingChanged()`, etc.)
* [markAllMessagesAsRead](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread.md#mark-messages-as-read-all-channels)
* [reconnectSubscriptions()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md#reconnect-subscriptions)
* [registerPushChannels()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications.md#register-selected-push-channels)
* [removeChannelGroup()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/channel-groups.md#remove-channel-group)
* [unregisterAllPushChannels()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications.md#unregister-all-push-channels)
* [unregisterPushChannels()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/push-notifications.md#unregister-selected-push-channels)
* [updateChannel()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/updates.md#update-channel-details)
* [updateUser()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/updates.md#update-user-details)
* [wherePresent()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence.md#return-channels-where-user-is-present)
* [whoIsPresent()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence.md#return-all-users-present-on-channel)

## Event listeners

You can call the following event listener methods on the `Chat` object.

Click on each method for more details.

* [addConnectionStatusListener()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/configuration.md#listen-for-connection-status)

## Use case

For example, you can use the `Chat` object methods to:

* Create a [channel](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/create.md) or [user](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/create.md).
* Get [channel](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/details.md) or [user](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/details.md#get-user-details) data.

Last updated at: 2026-05-12T11:37:48.000Z
