Skip to main content
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

Where It Fits

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

Put it in a NavigationStack — as a tab’s root, it needs nothing else:
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:
"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.

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.
Hide the chips:
Narrow what “All” loads with your own request:

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.
The title — “Notifications” — sits on the left of the navigation bar. Change it, replace it, or hide it:
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:

Actions and Events

Callback Methods

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


Functionality


Custom View Slots

Replace a state with your own view.
The header and the three state views are initialiser arguments (headerView, emptyStateView, errorStateView, loadingStateView). The error view receives the exception and the retry action:

Common Patterns

List operations

List operations go through the store — see Store Access below.

Advanced Methods

Store Access

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:
A seeded store never fetches, reports or listens.

Subclassing

CometChatNotificationFeed is a View struct. Customise it with its slots and style.

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

CometChatNotificationFeedStyle is sparse: set only what you change.
The four card colours reach the cards renderer as its theme override; leave them unset to keep the card’s own colours.

Next Steps

Component Styling

Style every component

Extensions

Add features to your chat