> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Real-time Events

> Subscribe to subchannel topics for live chat thread updates.

Chat real-time event subscriptions keep a thread's live data moving while the user is viewing it. For the current SDK surface, the public chat topic documented here is the subchannel topic.

> [!NOTE]
>
> Conversation and community channel members receive many chat updates through normal SDK live objects and collections. Use a subchannel topic when the screen needs explicit realtime delivery for a specific message thread.

## Platform Surface

| Platform | Public API | Cleanup |
| - | - | - |
| TypeScript | `getSubChannelTopic(subChannel)`, then `subscribeTopic(topic)` | Call the returned `Amity.Unsubscriber` |
| iOS | `AmitySubChannelTopic(subChannel:)`, then `AmityTopicSubscription().subscribeTopic(...)` | `AmityTopicSubscription().unsubscribeTopic(...)` |
| Android | `subChannel.subscription().subscribeTopic()` | `subChannel.subscription().unsubscribeTopic()` |
| Flutter | `subChannel.subscription().subscribeTopic()` | `subChannel.subscription().unsubscribeTopic()` |

## Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | `subChannel` | Yes | `Amity.SubChannel` model returned by the SDK. The helper reads its `path` and subscribes to that path with a wildcard. |
| iOS | `subChannel` | Yes | `AmitySubChannel` model used to construct `AmitySubChannelTopic`. |
| Android | `subChannel` | Yes | `AmitySubChannel` model exposing the public `subscription()` method. |
| Flutter | `subChannel` | Yes | `AmitySubChannel` model exposing the public `subscription()` method. |

## Subscribe To A Subchannel

Subscribe when the thread screen becomes active, and unsubscribe when it leaves the screen or switches to another subchannel.

```typescript TypeScript theme={null}
import { getSubChannelTopic, subscribeTopic } from '@amityco/ts-sdk';

function subscribeToSubChannel(subChannel: Amity.SubChannel): Amity.Unsubscriber {
  const topic = getSubChannelTopic(subChannel);

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToSubChannel(_ subChannel: AmitySubChannel) async throws {
    let topic = AmitySubChannelTopic(subChannel: subChannel)

    try await AmityTopicSubscription().subscribeTopic(topic)
}

func unsubscribeFromSubChannel(_ subChannel: AmitySubChannel) async throws {
    let topic = AmitySubChannelTopic(subChannel: subChannel)

    try await AmityTopicSubscription().unsubscribeTopic(topic)
}
```

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.chat.subchannel.AmitySubChannel

fun subscribeToSubChannel(subChannel: AmitySubChannel) {
    subChannel.subscription()
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}

fun unsubscribeFromSubChannel(subChannel: AmitySubChannel) {
    subChannel.subscription()
        .unsubscribeTopic()
        .subscribe()
}
```

```dart Flutter theme={null}
Future<void> subscribeToSubChannel(AmitySubChannel subChannel) async {
  await subChannel.subscription().subscribeTopic();
}

Future<void> unsubscribeFromSubChannel(AmitySubChannel subChannel) async {
  await subChannel.subscription().unsubscribeTopic();
}
```

## Best Practices

> [accordion] Subscribe per visible thread
>
> Bind the subchannel subscription to the active message thread, not to the entire chat module. Switch the subscription when the user changes threads.

> [accordion] Keep the model source explicit
>
> The snippets expect a real `SubChannel` model returned by the SDK. Avoid constructing topic paths manually in app code.

> [accordion] Use live collections for rendering
>
> After subscribing, render messages from the SDK query or live collection APIs so local cache updates and pagination stay consistent.

## Related Topics

> [card] [Messages](/social-plus-sdk/chat/messaging-features/messages/query-and-filter-messages.md)
>
> Query and render messages for a subchannel.

> [card] [Live Objects & Collections](/social-plus-sdk/core-concepts/realtime-communication/live-objects-collections/overview.md)
>
> Understand how realtime events update observed SDK data.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.