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

# Social Real-time Events

> Subscribe to community, post, comment, user, follow, and story topic events.

Social real-time events let an app receive live updates for the social models that are currently visible. Use topic subscriptions for the event stream, then render from the SDK live object or live collection for the model.

> [!NOTE]
>
> Community and user-scoped topics are useful for feed screens. Post and comment topics are better for focused detail screens. The user must have access to the target community, post, comment, user, or story for events to be delivered.

## Platform Surface

| Topic | TypeScript | iOS | Android | Flutter |
| - | - | - | - | - |
| Community | `getCommunityTopic(...)` | `AmityCommunityTopic` | `community.subscription(...)` | `community.subscription(...)` |
| Post | `getPostTopic(...)`, `getLiveReactionTopic(...)` | `AmityPostTopic` | `post.subscription(...)` | `post.subscription(...)` |
| Comment | `getCommentTopic(...)` | `AmityCommentTopic` | `comment.subscription(...)` | `comment.subscription(...)` |
| User | `getUserTopic(...)` | `AmityUserTopic` | `user.subscription(...)` | `user.subscription(...)` |
| Follow | `getMyFollowersTopic()`, `getMyFollowingsTopic()` | `AmityFollowTopic` | `AmityCoreClient.subscription(AmityTopic.FOLLOW(...))` | Not exposed in this checkout |
| Story | `getStoryTopic(...)`, `getCommunityStoriesTopic(...)` | `AmityStoryTopic` | `story.subscription()` | `story.subscription()` |

## Community Topic

Use a community topic when a screen is scoped to a community, such as a community profile, feed, or moderation surface.

### Event Levels

| Intent | TypeScript | iOS | Android | Flutter |
| - | - | - | - | - |
| Community object changes | `SubscriptionLevels.COMMUNITY` or omit the level | `.community` | `AmityCommunityEvents.COMMUNITY` | `AmityCommunityEvents.COMMUNITY` |
| Posts in the community | `SubscriptionLevels.POST` | `.posts` | `AmityCommunityEvents.POSTS` | `AmityCommunityEvents.POSTS` |
| Comments in the community | `SubscriptionLevels.COMMENT` | `.comments` | `AmityCommunityEvents.COMMENTS` | `AmityCommunityEvents.COMMENTS` |
| Posts and comments | `SubscriptionLevels.POST_AND_COMMENT` | `.postsAndComments` | `AmityCommunityEvents.POSTS_AND_COMMENTS` | `AmityCommunityEvents.POSTS_AND_COMMENTS` |
| Stories and story comments | Use `getCommunityStoriesTopic(...)` | `.storyAndComments` | `AmityCommunityEvents.STORIES_AND_COMMENTS` | `AmityCommunityEvents.STORIES_AND_COMMENTS` |

### Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | `community` | Yes | `Amity.Community` or any subscribable object with a valid `path`. |
| TypeScript | `level` | No | Defaults to `SubscriptionLevels.COMMUNITY`. Use `POST`, `COMMENT`, or `POST_AND_COMMENT` for content updates. |
| iOS | `community` | Yes | `AmityCommunity` model used to construct `AmityCommunityTopic`. |
| iOS | `andEvent` | Yes | One `AmityCommunityEvent` value. |
| Android | `events` | Yes | One `AmityCommunityEvents` value passed to `community.subscription(events)`. |
| Flutter | `events` | Yes | One `AmityCommunityEvents` value passed to `community.subscription(events)`. |

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

function subscribeToCommunityFeed(community: Amity.Community): Amity.Unsubscriber {
  const topic = getCommunityTopic(
    community,
    SubscriptionLevels.POST_AND_COMMENT,
  );

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToCommunityFeed(_ community: AmityCommunity) async throws {
    let topic = AmityCommunityTopic(
        community: community,
        andEvent: .postsAndComments
    )

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.core.events.AmityCommunityEvents
import com.amity.socialcloud.sdk.model.social.community.AmityCommunity

fun subscribeToCommunityFeed(community: AmityCommunity) {
    community.subscription(AmityCommunityEvents.POSTS_AND_COMMENTS)
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}
```

```dart Flutter theme={null}
Future<void> subscribeToCommunityFeed(AmityCommunity community) async {
  await community
      .subscription(AmityCommunityEvents.POSTS_AND_COMMENTS)
      .subscribeTopic();
}
```

## Post Topic

Use a post topic for a single post detail screen or a moderation/action surface focused on one post.

### Event Levels

| Intent | TypeScript | iOS | Android | Flutter |
| - | - | - | - | - |
| Post object changes | `getPostTopic(post)` or `SubscriptionLevels.POST` | `.post` | `AmityPostEvents.POST` | `AmityPostEvents.POST` |
| Comments on the post | `SubscriptionLevels.COMMENT` | `.comments` | `AmityPostEvents.COMMENTS` | `AmityPostEvents.COMMENTS` |
| Live reactions | `getLiveReactionTopic(post)` | `.liveReaction` | `AmityPostEvents.LIVE_REACTION` | Not exposed in this checkout |

### Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | `post` | Yes | `Amity.Post` or subscribable post object with a valid `path`. |
| TypeScript | `level` | No | Defaults to post object events. Use `SubscriptionLevels.COMMENT` for post comments. |
| iOS | `post` | Yes | `AmityPost` model used to construct `AmityPostTopic`. |
| iOS | `andEvent` | Yes | One `AmityPostEvent` value. |
| Android | `events` | Yes | One `AmityPostEvents` value passed to `post.subscription(events)`. |
| Flutter | `events` | Yes | One `AmityPostEvents` value passed to `post.subscription(events)`. |

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

function subscribeToPostComments(post: Amity.Post): Amity.Unsubscriber {
  const topic = getPostTopic(post, SubscriptionLevels.COMMENT);

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToPostComments(_ post: AmityPost) async throws {
    let topic = AmityPostTopic(post: post, andEvent: .comments)

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.core.events.AmityPostEvents
import com.amity.socialcloud.sdk.model.social.post.AmityPost

fun subscribeToPostComments(post: AmityPost) {
    post.subscription(AmityPostEvents.COMMENTS)
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}
```

```dart Flutter theme={null}
Future<void> subscribeToPostComments(AmityPost post) async {
  await post
      .subscription(AmityPostEvents.COMMENTS)
      .subscribeTopic();
}
```

## Comment Topic

Use a comment topic for a focused comment detail, moderation, or realtime reply surface.

### Event Levels

| Intent | TypeScript | iOS | Android | Flutter |
| - | - | - | - | - |
| Comment object changes | `getCommentTopic(comment)` | `.comment` | `AmityCommentEvents.COMMENT` | `AmityCommentEvents.COMMENT` |

### Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | `comment` | Yes | `Amity.Comment` or subscribable comment object with a valid `path`. |
| iOS | `comment` | Yes | `AmityComment` model used to construct `AmityCommentTopic`. |
| iOS | `andEvent` | Yes | `.comment`. |
| Android | `events` | Yes | `AmityCommentEvents.COMMENT`. |
| Flutter | `events` | Yes | `AmityCommentEvents.COMMENT`. |

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

function subscribeToComment(comment: Amity.Comment): Amity.Unsubscriber {
  const topic = getCommentTopic(comment);

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToComment(_ comment: AmityComment) async throws {
    let topic = AmityCommentTopic(comment: comment, andEvent: .comment)

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.core.events.AmityCommentEvents
import com.amity.socialcloud.sdk.model.social.comment.AmityComment

fun subscribeToComment(comment: AmityComment) {
    comment.subscription(AmityCommentEvents.COMMENT)
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}
```

```dart Flutter theme={null}
Future<void> subscribeToComment(AmityComment comment) async {
  await comment
      .subscription(AmityCommentEvents.COMMENT)
      .subscribeTopic();
}
```

## User Topic

Use a user topic when a screen needs live updates for a user profile or that user's feed activity.

### Event Levels

| Intent | TypeScript | iOS | Android | Flutter |
| - | - | - | - | - |
| User object changes | `SubscriptionLevels.USER` or omit the level | `.user` | `AmityUserEvents.USER` | `AmityUserEvents.USER` |
| User posts | `SubscriptionLevels.POST` | `.posts` | `AmityUserEvents.POSTS` | `AmityUserEvents.POSTS` |
| User comments | `SubscriptionLevels.COMMENT` | `.comments` | `AmityUserEvents.COMMENTS` | `AmityUserEvents.COMMENTS` |
| User posts and comments | `SubscriptionLevels.POST_AND_COMMENT` | `.postsAndComments` | `AmityUserEvents.POSTS_AND_COMMENTS` | `AmityUserEvents.POSTS_AND_COMMENTS` |

### Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | `user` | Yes | `Amity.User` or subscribable user object with a valid `path`. |
| TypeScript | `level` | No | Defaults to `SubscriptionLevels.USER`. Use content levels for user-feed activity. |
| iOS | `user` | Yes | `AmityUser` model used to construct `AmityUserTopic`. |
| iOS | `andEvent` | Yes | One `AmityUserEvent` value. |
| Android | `events` | Yes | One `AmityUserEvents` value passed to `user.subscription(events)`. |
| Flutter | `events` | Yes | One `AmityUserEvents` value passed to `user.subscription(events)`. |

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

function subscribeToUserPosts(user: Amity.User): Amity.Unsubscriber {
  const topic = getUserTopic(user, SubscriptionLevels.POST);

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToUserPosts(_ user: AmityUser) async throws {
    let topic = AmityUserTopic(user: user, andEvent: .posts)

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.core.events.AmityUserEvents
import com.amity.socialcloud.sdk.model.core.user.AmityUser

fun subscribeToUserPosts(user: AmityUser) {
    user.subscription(AmityUserEvents.POSTS)
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}
```

```dart Flutter theme={null}
Future<void> subscribeToUserPosts(AmityUser user) async {
  await user
      .subscription(AmityUserEvents.POSTS)
      .subscribeTopic();
}
```

## Follow Topic

Follow topics observe changes to the current user's follower and following lists.

> [!WARNING]
>
> The current Flutter SDK checkout does not expose a public follow topic subscription helper. Use this section for TypeScript, iOS, and Android.

### Event Levels

| Intent | TypeScript | iOS | Android |
| - | - | - | - |
| Current user's followers | `getMyFollowersTopic()` | `.myFollowers` | `AmityFollowEvents.MY_FOLLOWERS` |
| Current user's following | `getMyFollowingsTopic()` | `.myFollowing` | `AmityFollowEvents.MY_FOLLOWINGS` |

### Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | None | No | Helpers derive the current user from the active SDK user. |
| iOS | `event` | Yes | One `AmityFollowEvent` value. |
| Android | `events` | Yes | One `AmityFollowEvents` value used to construct `AmityTopic.FOLLOW(...)`. |

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

function subscribeToMyFollowers(): Amity.Unsubscriber {
  const topic = getMyFollowersTopic();

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToMyFollowers() async throws {
    let topic = AmityFollowTopic(event: .myFollowers)

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.api.core.AmityCoreClient
import com.amity.socialcloud.sdk.model.core.events.AmityFollowEvents
import com.amity.socialcloud.sdk.model.core.events.AmityTopic

fun subscribeToMyFollowers() {
    AmityCoreClient.subscription(AmityTopic.FOLLOW(AmityFollowEvents.MY_FOLLOWERS))
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}
```

## Story Topic

Story topics observe one story or a community's story stream.

### Event Levels

| Intent | TypeScript | iOS | Android | Flutter |
| - | - | - | - | - |
| One story | `getStoryTopic(story)` | `AmityStoryTopic(story:andEvent:)` with `.story` | `story.subscription()` | `story.subscription()` |
| Community story stream | `getCommunityStoriesTopic(...)` | Community topic `.storyAndComments` | Community topic `STORIES_AND_COMMENTS` | Community topic `STORIES_AND_COMMENTS` |

### Parameters

| Platform | Parameter | Required | Description |
| - | - | - | - |
| TypeScript | `story` | Yes | Object with `targetId`, `targetType`, and `storyId` for `getStoryTopic`. |
| TypeScript | `targetId`, `targetType` | Yes | Community or user story target passed to `getCommunityStoriesTopic`. |
| iOS | `story` | Yes | `AmityStory` model used to construct `AmityStoryTopic`. |
| iOS | `andEvent` | Yes | `.story`. |
| Android | `story` | Yes | `AmityStory` model exposing `subscription()`. |
| Flutter | `story` | Yes | `AmityStory` model exposing `subscription()`. |

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

function subscribeToStory(
  story: Pick<Amity.Story, 'targetId' | 'targetType' | 'storyId'>,
): Amity.Unsubscriber {
  const topic = getStoryTopic(story);

  return subscribeTopic(topic);
}
```

```swift iOS theme={null}
func subscribeToStory(_ story: AmityStory) async throws {
    let topic = AmityStoryTopic(story: story, andEvent: .story)

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.social.story.AmityStory
import com.amity.socialcloud.sdk.model.social.story.subscription

fun subscribeToStory(story: AmityStory) {
    story.subscription()
        .subscribeTopic()
        .subscribe({
            showSuccessMessage("Subscribed")
        }, { error ->
            showErrorMessage(error = error)
        })
}
```

```dart Flutter theme={null}
Future<void> subscribeToStory(AmityStory story) async {
  await story.subscription().subscribeTopic();
}
```

## Cleanup

Use the platform-specific unsubscribe path when the UI no longer needs the topic.

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

function mountCommunityFeed(community: Amity.Community): Amity.Unsubscriber {
  const topic = getCommunityTopic(
    community,
    SubscriptionLevels.POST_AND_COMMENT,
  );

  return subscribeTopic(topic);
}

const unsubscribe = mountCommunityFeed(community);
unsubscribe();
```

```swift iOS theme={null}
func unsubscribeFromCommunityFeed(_ community: AmityCommunity) async throws {
    let topic = AmityCommunityTopic(
        community: community,
        andEvent: .postsAndComments
    )

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

```kotlin Android theme={null}
import com.amity.socialcloud.sdk.model.core.events.AmityCommunityEvents
import com.amity.socialcloud.sdk.model.social.community.AmityCommunity

fun unsubscribeFromCommunityFeed(community: AmityCommunity) {
    community.subscription(AmityCommunityEvents.POSTS_AND_COMMENTS)
        .unsubscribeTopic()
        .subscribe()
}
```

```dart Flutter theme={null}
Future<void> unsubscribeFromCommunityFeed(AmityCommunity community) async {
  await community
      .subscription(AmityCommunityEvents.POSTS_AND_COMMENTS)
      .unsubscribeTopic();
}
```

## Related Topics

> [card] [Real-time Events Overview](/social-plus-sdk/core-concepts/realtime-communication/realtime-events/overview.md)
>
> Learn how topic subscriptions fit with live objects and collections.

> [card] [Chat Real-time Events](/social-plus-sdk/core-concepts/realtime-communication/realtime-events/chat-realtime-events.md)
>
> Subscribe to subchannel topics for chat threads.


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