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

# Community Notification Settings

> Read and update push notification settings for one community.

Community notification settings control whether the signed-in user receives push notifications from one community. You can also pass event modifiers to enable or disable specific community notification events.

## API surface

| Platform   | Manager                                                    | Read            | Enable                    | Disable     |
| ---------- | ---------------------------------------------------------- | --------------- | ------------------------- | ----------- |
| TypeScript | `Client.notifications().community(communityId)`            | `getSettings()` | `enable(events?)`         | `disable()` |
| iOS        | `communityRepository.notificationManager(forCommunityId:)` | `getSettings()` | `enable(events:)`         | `disable()` |
| Android    | `AmityCoreClient.notifications().community(communityId)`   | `getSettings()` | `enable(eventModifiers?)` | `disable()` |
| Flutter    | `AmityCoreClient.notifications().community(communityId)`   | `getSettings()` | `enable(eventModifiers)`  | `disable()` |

## Parameters

| Name             | Platform                          | Type                                 | Required                           | Description                                                                  |
| ---------------- | --------------------------------- | ------------------------------------ | ---------------------------------- | ---------------------------------------------------------------------------- |
| `communityId`    | TypeScript, iOS, Android, Flutter | `String` / `string`                  | Yes                                | ID of the community whose push setting should be read or updated.            |
| `events`         | TypeScript, iOS                   | Community notification event list    | No on TypeScript, yes on iOS       | Event-level modifiers to send with `enable`.                                 |
| `eventModifiers` | Android, Flutter                  | Community notification modifier list | No on Android, nullable on Flutter | Event-level modifiers to send with `enable`.                                 |
| `roleFilter`     | TypeScript, iOS, Android, Flutter | Role filter                          | No                                 | Optional filter for receiving notifications only from matching sender roles. |

## Community events

| Event value                | TypeScript enum         | iOS case               | Android modifier        | Flutter modifier      |
| -------------------------- | ----------------------- | ---------------------- | ----------------------- | --------------------- |
| `post.created`             | `POST_CREATED`          | `.postCreated`         | `POST_CREATED`          | `PostCreated`         |
| `post.reacted`             | `POST_REACTED`          | `.postReacted`         | `POST_REACTED`          | `PostReacted`         |
| `comment.created`          | `COMMENT_CREATED`       | `.commentCreated`      | `COMMENT_CREATED`       | `CommentCreated`      |
| `comment.replied`          | `COMMENT_REPLIED`       | `.commentReplied`      | `COMMENT_REPLIED`       | `CommentReplied`      |
| `comment.reacted`          | `COMMENT_REACTED`       | `.commentReacted`      | `COMMENT_REACTED`       | `CommentReacted`      |
| `story.created`            | `STORY_CREATED`         | `.storyCreated`        | `STORY_CREATED`         | `StoryCreated`        |
| `story.reacted`            | `STORY_REACTED`         | `.storyReacted`        | `STORY_REACTED`         | `StoryReacted`        |
| `story-comment.created`    | `STORY_COMMENT_CREATED` | `.storyCommentCreated` | `STORY_COMMENT_CREATED` | `StoryCommentCreated` |
| `video-streaming.didStart` | `LIVESTREAM_START`      | `.livestreamStart`     | `LIVESTREAM_START`      | Not exposed           |

<Note>
  Flutter exposes `video-streaming` as a user notification module, but this checkout does not expose a community-level livestream-start event modifier.
</Note>

## Get community settings

Read community notification settings before rendering community-level or event-level push controls.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { Client } from '@amityco/ts-sdk';

  const settings = await Client.notifications()
    .community(communityId)
    .getSettings();

  const isEnabled = settings.isEnabled;

  settings.events.forEach(event => {
    const eventName = event.eventName;
    const eventEnabled = event.isEnabled;
    const networkEnabled = event.isNetworkEnabled;

    updateUI({ eventName, eventEnabled, networkEnabled });
  });
  ```

  ```swift iOS theme={null}
  let notificationManager = communityRepository.notificationManager(forCommunityId: communityId)
  let settings = try await notificationManager.getSettings()

  let isEnabled = settings.isEnabled

  for event in settings.events {
      print("- event \(event.eventName) enabled: \(event.isEnabled)")
  }
  ```

  ```kotlin Android theme={null}
  AmityCoreClient.notifications()
      .community(communityId)
      .getSettings()
      .doOnSuccess { settings: AmityCommunityNotificationSettings ->
          val isEnabled = settings.isEnabled()

          settings.getNotificationEvents().forEach { event ->
              when (event) {
                  is AmityCommunityNotificationEvent.POST_CREATED -> {
                      val eventEnabled = event.isEnabled()
                      val networkEnabled = event.isNetworkEnabled()
                  }
                  else -> Unit
              }
          }
      }
      .doOnError { error ->
          // Handle error.
      }
      .subscribe()
  ```

  ```dart Flutter theme={null}
  final settings = await AmityCoreClient
      .notifications()
      .community(communityId)
      .getSettings();

  final isEnabled = settings.isEnabled;

  settings.events?.forEach((event) {
    final eventEnabled = event.isEnabled;
    final networkEnabled = event.isNetworkEnabled;
  });
  ```
</CodeGroup>

## Update community settings

Enable, disable, or customize community notification events after the user changes community push preferences.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import {
    Client,
    CommunityNotificationEventNameEnum,
    NotificationRolesFilterTypeEnum,
  } from '@amityco/ts-sdk';

  await Client.notifications()
    .community(communityId)
    .enable([
      {
        eventName: CommunityNotificationEventNameEnum.POST_CREATED,
        isEnabled: true,
        rolesFilter: {
          type: NotificationRolesFilterTypeEnum.ONLY,
          roleIds: ['community-moderator'],
        },
      },
      {
        eventName: CommunityNotificationEventNameEnum.STORY_REACTED,
        isEnabled: false,
      },
    ]);

  await Client.notifications()
    .community(communityId)
    .disable();
  ```

  ```swift iOS theme={null}
  let notificationManager = communityRepository.notificationManager(forCommunityId: communityId)

  try await notificationManager.enable(events: [
      AmityCommunityNotificationEvent(
          eventType: .postCreated,
          isEnabled: true,
          roleFilter: AmityRoleFilter.onlyFilter(withRoleIds: ["community-moderator"])
      ),
      AmityCommunityNotificationEvent(
          eventType: .storyReacted,
          isEnabled: false,
          roleFilter: nil
      ),
  ])

  try await notificationManager.disable()
  ```

  ```kotlin Android theme={null}
  val rolesFilter = AmityRolesFilter.ONLY(AmityRoles(listOf("community-moderator")))

  val postCreatedModifier = AmityCommunityNotificationEvent.POST_CREATED.enable(rolesFilter)
  val storyReactedModifier = AmityCommunityNotificationEvent.STORY_REACTED.disable()

  AmityCoreClient.notifications()
      .community(communityId)
      .enable(
          eventModifiers = listOf(
              postCreatedModifier,
              storyReactedModifier
          )
      )
      .doOnComplete {
          // Community notification settings updated.
      }
      .doOnError { error ->
          // Handle error.
      }
      .subscribe()

  AmityCoreClient.notifications()
      .community(communityId)
      .disable()
      .subscribe()
  ```

  ```dart Flutter theme={null}
  final rolesFilter = Only(AmityRoles(roles: ['community-moderator']));

  await AmityCoreClient
      .notifications()
      .community(communityId)
      .enable([
        PostCreated.enable(rolesFilter),
        StoryReacted.disable(),
      ]);

  await AmityCoreClient
      .notifications()
      .community(communityId)
      .disable();
  ```
</CodeGroup>

## Related

<CardGroup cols={2}>
  <Card title="User Settings" href="./user-settings">
    Configure account-wide push preferences and module modifiers.
  </Card>

  <Card title="Channel Settings" href="./channel-settings">
    Configure push settings for a chat channel.
  </Card>
</CardGroup>
