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

# Notification Feed

> The notifications your app sends to a user — campaigns, announcements, product cards — with category filters, unread badges and read tracking.

`CometChatNotificationFeed` shows the notifications your app has sent to the logged-in user:
campaigns, announcements, reminders, product cards. Each item is a card drawn from its Card
Schema, with its category and the time it was sent above it. Filter chips — "All" and one per
category — sit at the top, each with its unread count. Items are marked delivered when they load
and read after they have been on screen for a second; new items arrive live.

![CometChatNotificationFeed showing notification cards with category chips](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-notification-feed.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=a056435e09e46849d38bcc3c7e2ce6ec)

***

## Where It Fits

```
Tab bar ── "Notifications"
                │
                ▼
┌─────────────────────────────────────┐
│ CometChatNotificationFeed  ← here   │
│  [All 3] [Promotions 2] [Updates]   │
│  Promotions                 10:42   │
│  ┌───────────────────────────────┐  │
│  │ card                          │  │
│  └───────────────────────────────┘  │
└─────────────────────────────────────┘
        │ onItemClick / onActionClick
        ▼
   your screen for that notification
```

The feed is user-level: it needs no user or group. It loads the first page when it appears,
the next page as you scroll near the end, and the first page again when you pull to refresh.

***

## Quick Start

> [tab] SwiftUI
>
> Put it in a `NavigationStack` — as a tab's root, it needs nothing else:
>
> ```swift theme={null}
> struct NotificationsTab: View {
>     var body: some View {
>         NavigationStack {
>             CometChatNotificationFeed(onItemClick: { item in
>                 openNotification(item)
>             })
>         }
>     }
> }
> ```
>
> `onItemClick` receives the SDK's `NotificationFeedItem` — its `id`, `category`, `content`
> (the card), `metadata` and `tags`.
>
> A button inside a card calls `onActionClick` with the item and a dictionary: `"type"` is the
> card action's type (`openUrl`, `chatWithUser`, `customCallback`, …) and `"elementId"` the id of
> the element that was tapped:
>
> ```swift theme={null}
> CometChatNotificationFeed(onActionClick: { item, action in
>     let type = action["type"] as? String
>     handleNotificationAction(item, type: type)
> })
> ```
>
> `"action"` carries the card action itself, a `CometChatCardAction` (`import CometChatCardsSwift`):
> an `openUrl`'s URL, a `chatWithUser`'s uid. Match it — `if case .openUrl(let url, _) = action["action"]
>     as? CometChatCardAction` — to act on the button as the card describes it.

> [tab] UIKit
>
> `CometChatNotificationFeed` is a view controller. Make it a tab's root:
>
> ```swift theme={null}
> let feed = CometChatNotificationFeed()
>     .set(onItemClick: { item in openNotification(item) })
> let tab = UINavigationController(rootViewController: feed)
> tab.tabBarItem = UITabBarItem(title: "Notifications", image: UIImage(systemName: "bell"), tag: 4)
> ```
>
> `onItemClick` receives the SDK's `NotificationFeedItem` — its `id`, `category`, `content` (the
> card), `metadata` and `tags`.
>
> A button inside a card calls `onActionClick` with the item and the renderer's event — its
> `action` (`.openUrl`, `.chatWithUser`, `.customCallback`, …) and the `elementId` tapped:
>
> ```swift theme={null}
> let feed = CometChatNotificationFeed()
>     .set(onActionClick: { item, event in
>         handleNotificationAction(item, type: event.action.type)
>     })
> ```

***

## Filtering Notifications

The chips are "All" and one per category the server returns, in its order. Tapping a chip
loads that category's items; the category labels above the cards are hidden while one is
selected. Each chip's badge is its unread count, shown as "99+" above 99.

The "All" count refreshes every 30 seconds, and the first count arrives 30 seconds after the
screen opens, so the badge reads nothing until then. A category's count only moves as items
arrive live and are read — it is not fetched.

The request applies to "All"; a chip's request uses the default page size and the chip's
category.

> [tab] SwiftUI
>
> Hide the chips:
>
> ```swift theme={null}
> CometChatNotificationFeed(showFilterChips: false)
> ```
>
> Narrow what "All" loads with your own request:
>
> ```swift theme={null}
> let request = NotificationFeedRequest.NotificationFeedRequestBuilder()
>     .set(limit: 30)
>     .set(readState: .unread)
>
> CometChatNotificationFeed(feedRequestBuilder: request)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let feed = CometChatNotificationFeed()
>     .set(showFilterChips: false)
>     .set(notificationFeedRequestBuilder: NotificationFeedRequest.NotificationFeedRequestBuilder().set(limit: 30))
> ```

***

## Read and Delivered

Every item that loads or arrives without a delivery time is reported delivered, once. An unread
item that stays on screen for a second is reported read; the badges count it down. Scrolling it
away before then does not count.

***

## Header

> [tab] SwiftUI
>
> The title — "Notifications" — sits on the left of the navigation bar. Change it, replace it, or
> hide it:
>
> ```swift theme={null}
> CometChatNotificationFeed(title: "Inbox")
> CometChatNotificationFeed(headerView: { AnyView(Label("Inbox", systemImage: "tray")) })
> CometChatNotificationFeed(showHeader: false)
> ```
>
> The back button is off by default — the feed is usually a tab. Turn it on when you push it.
> With no `onBackPress`, it dismisses the screen:
>
> ```swift theme={null}
> CometChatNotificationFeed(showBackButton: true, onBackPress: { log("back") })
> ```

> [tab] UIKit
>
> `set(title:)` changes the title. The back button shows beside the title when there is a screen
> to go back to; `set(showBackButton: false)` hides it.

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Prop | Signature | When |
> | - | - | - |
> | `onItemClick` | `(NotificationFeedItem) -> Void` | a card is tapped |
> | `onActionClick` | `(NotificationFeedItem, [String: Any]) -> Void` | a button inside a card is tapped |
> | `onError` | `(CometChatException) -> Void` | the error state appears |
> | `onBackPress` | `(() -> Void)?` | the back button is tapped; the default dismisses |

> [tab] UIKit
>
> | Setter | Signature | When |
> | - | - | - |
> | `set(onItemClick:)` | `(NotificationFeedItem) -> Void` | a card is tapped |
> | `set(onActionClick:)` | `(NotificationFeedItem, CometChatCardActionEvent) -> Void` | a button inside a card is tapped |
> | `set(onError:)` | `(CometChatException) -> Void` | the error state appears |

`onError` is called each time the error state appears — a failed first load or refresh.

### SDK Events (Real-Time, Automatic)

New items arrive live and are added to the list; the badges follow as items are read.

***

## States

| State | Shows |
| - | - |
| loading | four placeholder cards |
| content | the cards; a spinner while the next page loads, "Couldn't load more · Tap to retry" if it failed |
| empty | "Nothing here yet" and "New activity will appear here when available." |
| error | "Oops!", "Looks like something went wrong. Please try again." and **Retry** |

***

## Functionality

> [tab] SwiftUI
>
> | Prop | Type | Default |
> | - | - | - |
> | `feedRequestBuilder` | `NotificationFeedRequest.NotificationFeedRequestBuilder?` | limit 20 |
> | `categoriesRequestBuilder` | `NotificationCategoriesRequest.NotificationCategoriesRequestBuilder?` | limit 50 |
> | `store` | `NotificationFeedStore?` | `nil` |
> | `title` | `String` | "Notifications" |
> | `showHeader` | `Bool` | `true` |
> | `showBackButton` | `Bool` | `false` |
> | `showFilterChips` | `Bool` | `true` |
> | `style` | `CometChatNotificationFeedStyle` | |

> [tab] UIKit
>
> | Method | Does |
> | - | - |
> | `set(notificationFeedRequestBuilder:)` | sets the `NotificationFeedRequest.NotificationFeedRequestBuilder` |
> | `set(notificationCategoriesRequestBuilder:)` | sets the `NotificationCategoriesRequest.NotificationCategoriesRequestBuilder` |
> | `set(showFilterChips:)`, `set(showBackButton:)` | shows or hides a part |
> | `set(cardThemeMode:)` | picks the card's light or dark theme: `"auto"`, `"light"` or `"dark"` |
> | `set(title:)` | sets the title |
> | `set(style:)` | applies a `NotificationFeedStyle` |
> | `insert(feedItem:at:)`, `remove(feedItemId:)`, `clearList()` | change the listed items |
> | `size()`, `getFeedItems()`, `getUnreadCount()` | read the list |
> | `refresh()` | refreshes the list |
> | `connect()`, `disconnect()` | start and stop the live listener and the unread polling |
>
> Also properties: `viewModel`, `style`, `showFilterChips`, `showBackButton`, `cardThemeMode`,
> `dateTimeFormatter` and `listItemCellClass`.

***

## Custom View Slots

Replace a state with your own view.

> [tab] SwiftUI
>
> The header and the three state views are initialiser arguments (`headerView`, `emptyStateView`,
> `errorStateView`, `loadingStateView`). The error view receives the exception and the retry
> action:
>
> ```swift theme={null}
> CometChatNotificationFeed(
>     emptyStateView: { AnyView(Text("You're all caught up")) },
>     errorStateView: { error, retry in
>         AnyView(Button("Try again", action: retry))
>     },
>     loadingStateView: { AnyView(ProgressView()) },
>     onError: { error in log(error.errorDescription) }
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let feed = CometChatNotificationFeed()
>     .set(emptyView: MyEmptyView())
>     .set(onError: { error in log(error) })
> ```
>
> Replace the row with your own cell class through `listItemCellClass`.

***

## Common Patterns

### List operations

> [tab] SwiftUI
>
> List operations go through the store — see Store Access below.

> [tab] UIKit
>
> The list methods work over the screen's store:
>
> ```swift theme={null}
> let feed = CometChatNotificationFeed()
> feed.remove(feedItemId: "item-id")
> let count = feed.size()
> let unread = feed.getUnreadCount()
> feed.refresh()
> log("\(count) items, \(unread) unread")
> ```

***

## Advanced Methods

### Store Access

> [tab] SwiftUI
>
> `NotificationFeedStore` loads and holds the feed. Pass your own to read its state — `uiState`,
> `feedItems`, `filterChips`, `totalUnreadCount` — or to show fixed items in a preview:
>
> ```swift theme={null}
> #Preview {
>     NavigationStack {
>         CometChatNotificationFeed(store: NotificationFeedStore(
>             seeded: .sampleContent(), categories: ChatNotificationCategory.samples))
>     }
> }
> ```
>
> A seeded store never fetches, reports or listens.

> [tab] UIKit
>
> The screen's store is `viewModel`, a `NotificationFeedStore`.

### Subclassing

> [tab] SwiftUI
>
> `CometChatNotificationFeed` is a `View` struct. Customise it with its slots and style.

> [tab] UIKit
>
> These override points are `open`: `defaultSetup`, `setupStyle`, `setupViewModel`,
> `registerCells`, `reloadData`, `showEmptyView`, `showErrorView`, `showLoadingView` and the table
> methods. Replace the row with your own cell class:
>
> ```swift theme={null}
> final class CompactFeedCell: NotificationFeedItemCell {}
>
> @MainActor func makeFeed() -> CometChatNotificationFeed {
>     let feed = CometChatNotificationFeed()
>     feed.listItemCellClass = CompactFeedCell.self
>     return feed
> }
> ```

***

## Accessibility

In the SwiftUI toolkit:

* Each chip is a button with its unread count as its value; the active chip is selected.
* Each item is announced as "Notification from" its category; the card's buttons stay reachable
  inside it.
* The empty and error art is decorative; their titles are headers.

***

## Style

> [tab] SwiftUI
>
> `CometChatNotificationFeedStyle` is sparse: set only what you change.
>
> | Property | Default |
> | - | - |
> | `backgroundColor` | `background2` |
> | `headerBackgroundColor` | `background1` — the chip row and the bar: the bar's own fill below iOS 26, the colour under its Liquid Glass on iOS 26 |
> | `headerTitleColor`, `headerTitleFont` | `textPrimary`, `heading1Bold` |
> | `chipActiveBackgroundColor`, `chipActiveTextColor` | `primary`, `white` |
> | `chipInactiveBackgroundColor`, `chipInactiveTextColor`, `chipBorderColor` | `background1`, `textSecondary`, `strokeDefault` |
> | `badgeActiveBackgroundColor`, `badgeActiveBorderColor`, `badgeActiveTextColor` | `extendedPrimary50`, `extendedPrimary200`, `textHighlight` |
> | `badgeInactiveBackgroundColor`, `badgeInactiveTextColor` | `neutral600`, `white` |
> | `timestampTextColor`, `timestampFont` | `textSecondary`, `caption1Regular` — the category and the time |
> | `cardBackgroundColor`, `cardBorderColor`, `cardBorderRadius`, `cardBorderWidth` | clear, clear, 12, 0 |
> | `cardTitleColor`, `cardDescriptionColor`, `primaryButtonBackgroundColor`, `primaryButtonTextColor` | the card's own theme |
> | `emptyTitleColor`, `emptyDescriptionColor` | `textPrimary`, `textSecondary` — the empty and error states |
>
> ```swift theme={null}
> var style = CometChatNotificationFeedStyle()
> style.chipActiveBackgroundColor = .indigo
> style.cardBorderColor = .gray
> style.cardBorderWidth = 1
> style.primaryButtonBackgroundColor = .indigo
>
> CometChatNotificationFeed(style: style)
> ```
>
> The four card colours reach the cards renderer as its theme override; leave them unset to keep
> the card's own colours.

> [tab] UIKit
>
> Set the static default for every feed, or one screen's copy:
>
> ```swift theme={null}
> CometChatNotificationFeed.style.chipActiveBackgroundColor = .systemIndigo
>
> let feed = CometChatNotificationFeed()
> feed.style.cardBorderColor = .systemGray4
> feed.style.cardBorderWidth = 1
> feed.style.primaryButtonBackgroundColor = .systemIndigo
> ```
>
> | Property | Default |
> | - | - |
> | `backgroundColor` | `background2` |
> | `headerBackgroundColor` | `background1` — the chip row and the bar: the bar's own fill below iOS 26, the colour under its Liquid Glass on iOS 26 |
> | `titleFont`, `titleColor` | 24 bold, `textPrimary` |
> | `chipActive…`, `chipInactive…`, `chipBorderColor`, `chipBorderWidth`, `chipCornerRadius` | `primary` / `white`, `background1` / `textSecondary`, `strokeDefault`, 1, 17 |
> | `badgeActive…`, `badgeInactive…`, `badgeTextFont` | `extendedPrimary50` / `extendedPrimary200` / `textHighlight`, `neutral600` / `white`, `caption1Medium` |
> | `timestampHeaderTextColor`, `timestampValueColor` and their fonts | `textSecondary`, `caption1Regular` |
> | `cardBackgroundColor`, `cardBorderColor`, `cardBorderRadius`, `cardBorderWidth` | clear, clear, 12, 0 |
> | `cardTitleColor`, `cardDescriptionColor`, `primaryButtonBackgroundColor`, `primaryButtonTextColor`, `cardTitleFont`'s family | the card's own theme |
> | `emptyTitleTextFont`, `errorTitleTextFont`, … | `heading3Bold` / `bodyRegular` |
> | `retryButton…` | `primary`, `buttonText`, radius 8 |
>
> The card fields reach the cards renderer as its theme override. `set(cardThemeMode:)` picks the
> card's light or dark theme; `"auto"` follows the screen.

***

## Next Steps

> [card] [Component Styling](https://www.cometchat.com/docs/ui-kit/ios/v6/component-styling.md)
>
> Style every component

> [card] [Extensions](https://www.cometchat.com/docs/ui-kit/ios/v6/extensions.md)
>
> Add features to your chat


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