On this page

Chat object

The Chat object is your entry point to the Chat SDK after initialization. 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 Kotlin SDK

Properties

The Chat interface has the following properties:

1interface Chat {
2 val config: ChatConfiguration
3 val pubNub: PubNub
4 val currentUser: User
5 val syncMutedUsers: Boolean
6 val mutedUsersManager: MutedUsersManager
7
8 ...
9}
ParameterDescription
config
Type: ChatConfiguration
ChatConfiguration contains chat app configuration settings, such as logLevel or typingTimeout that you can provide when initializing your chat app with the init() method. You can later directly access these properties, like: chat.storeUserActivityInterval.
pubNub
Type: PubNub
pubNub lets you access any Kotlin SDK method. For example, if you want to call a method available in the App Context API, you'd use chat.pubNub.getAllUUIDMetadata().
currentUser
Type: User
User object representing current user.
syncMutedUsers
Type: Boolean
Whether the mute list is synchronized across sessions and devices. Corresponds to the syncMutedUsers configuration parameter.
mutedUsersManager
Type: MutedUsersManager
Manager object for muting and unmuting users on the client side. See Moderate misbehaving users for details.

ChatConfiguration includes these properties:

1interface ChatConfiguration {
2 val logLevel: LogLevel
3 val typingTimeout: Duration
4 val storeUserActivityInterval: Duration
5 val storeUserActivityTimestamps: Boolean
6 val pushNotifications: PushNotificationsConfig
7 val rateLimitFactor: Int
8 val rateLimitPerChannel: Map<ChannelType, Duration>
9 val customPayloads: CustomPayloads?
10 val emitReadReceiptEvents: Map<ChannelType, Boolean>
11 val syncMutedUsers: Boolean
12}

PushNotificationsConfig includes these properties:

1class PushNotificationsConfig(
2 val sendPushes: Boolean,
3 val deviceToken: String?,
4 val deviceGateway: PNPushType,
5 val apnsTopic: String?,
6 val apnsEnvironment: PNPushEnvironment
7)

Initialize the Chat SDK with two required parameters: subscribeKey and userId. All other settings are optional. See Configuration for details.

Methods

The Chat object exposes the following methods.

Regular methods

Event listeners

Use case

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