---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/event
title: Event object
updated_at: 2026-06-16T12:48:56.288Z
---

> 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


# Event object

`Event` represents a single piece of information emitted during chat operations: typing indicators, message receipts, mentions, or reports.

Unlike other Chat SDK entities, `Event` provides no methods - it only passes payloads emitted during chat operations.

## Properties

The `Event` interface has the following properties:

```swift
public protocol Event<T> {
  associatedtype C: Chat
  associatedtype T: EventContent
  
  var chat: C { get }
  var timetoken: Timetoken { get }
  var payload: T { get }
  var channelId: String { get }
  var userId: String { get }
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| chat | C | Optional |  | Reference to the main `ChatImpl` object. |
| timetoken | Timetoken | Optional |  | Timetoken of the message that triggered an event. |
| payload | T | Optional |  | Data passed in an event. For custom events, this is `EventContent.Custom` with a `data: [String: Any]` dictionary. Entity-specific events are delivered via dedicated callbacks (`onTypingChanged()`, `onMessageReported()`, `onReadReceiptReceived()`, `onMentioned()`, `onInvited()`, `onRestrictionChanged()`) rather than through this property. |
| channelId | String | Optional |  | Target channel where this event is delivered. |
| userId | String | Optional |  | [Unique ID](https://www.pubnub.com/docs/general/setup/users-and-devices) of the user that triggered the event. |

##### Event structure

The `EventContent` class has the following active subtypes:

```swift
public class EventContent {

  // MARK: - Custom

  public class Custom: EventContent {
    public let data: [String: Any]
    public let method: EmitEventMethod

    public init(data: [String : Any], method: EmitEventMethod) {
      self.data = data
      self.method = method
    }
  }

  // MARK: - TextMessageContent

  public class TextMessageContent: EventContent {
    public let text: String
    public let files: [File]?

    public init(text: String, files: [File]? = nil) {
      self.text = text
      self.files = files
    }
  }

  // MARK: - UnknownMessageFormat

  public class UnknownMessageFormat: EventContent {
    public let element: Any?

    public init(element: Any? = nil) {
      self.element = element
    }
  }
}
```

For details, refer to the [chat events documentation](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/custom-events).

## Use case

Events enable:

* Collecting historical chat events
* Creating [custom events](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/custom-events)
* Building moderation dashboards for flagged messages
* Triggering business logic with [Functions](https://www.pubnub.com/docs/serverless/functions/overview)