Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-feature-android-campaigns.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

CometChatNotificationFeed displays a scrollable notification feed where each item is rendered as a native card using the CometChat Cards library. It handles fetching, pagination, category filtering, timestamp grouping, real-time updates, and read/delivered/engagement reporting automatically.

Where It Fits

CometChatNotificationFeed is a full-screen component. Drop it into an Activity, Fragment, or navigation destination. It manages its own data fetching, state, and real-time listeners — you just handle navigation callbacks.
@Composable
fun NotificationsScreen(onBack: () -> Unit) {
    CometChatNotificationFeed(
        modifier = Modifier.fillMaxSize(),
        showBackButton = true,
        onBackPress = onBack,
        onItemClick = { item ->
            // Handle item tap (e.g., open detail or deep link)
        }
    )
}

Quick Start

@Composable
fun NotificationsScreen() {
    CometChatNotificationFeed(
        modifier = Modifier.fillMaxSize()
    )
}
Prerequisites: CometChat SDK initialized with CometChatUIKit.init() and a user logged in.

Filtering Feed Items

Control what loads using custom request builders:
CometChatNotificationFeed(
    feedRequestBuilder = NotificationFeedRequest.NotificationFeedRequestBuilder()
        .setLimit(30)
        .setReadState(FeedReadState.UNREAD)
        .setCategory("promotions")
)

Filter Options

Builder MethodDescription
.setLimit(int)Items per page (default 20, max 100)
.setReadState(FeedReadState)READ, UNREAD, or ALL
.setCategory(String)Filter by category ID
.setChannelId(String)Filter by channel
.setTags(List<String>)Filter by tags
.setDateFrom(String)ISO 8601 date lower bound
.setDateTo(String)ISO 8601 date upper bound
Pass the builder object, not the result of .build(). The component calls .build() internally.

Actions and Events

Callback Methods

onItemClick

Fires when a feed item card is tapped.
CometChatNotificationFeed(
    onItemClick = { item ->
        // item.id, item.content (Card JSON), item.category
    }
)

onActionClick

Fires when an interactive element (button, link) inside a card is tapped.
CometChatNotificationFeed(
    onActionClick = { item, actionMap ->
        // actionMap contains action type and parameters
        val actionType = actionMap["type"] as? String
        when (actionType) {
            "openUrl" -> openBrowser(actionMap["url"] as String)
            "chatWithUser" -> navigateToChat(actionMap["uid"] as String)
        }
    }
)

onError

Fires when an internal error occurs (network failure, SDK exception).
CometChatNotificationFeed(
    onError = { exception ->
        Log.e("Feed", "Error: ${exception.message}")
    }
)

onBackPress

Fires when the back button in the header is tapped.
CometChatNotificationFeed(
    showBackButton = true,
    onBackPress = { /* navigate back */ }
)

Automatic Behaviors

The component handles these automatically — no manual setup needed:
BehaviorDescription
Real-time updatesNew items appear at the top via WebSocket listener
Delivery reportingItems are reported as delivered when fetched
Read reportingItems are reported as read after 1 second of visibility
Unread count pollingPolls unread count every 30 seconds to update badges
Infinite scrollFetches next page when scrolling near the bottom
Pull-to-refreshResets and fetches fresh data on pull
Timestamp groupingGroups items as “Today”, “Yesterday”, day name, or date
Category filteringFilter chips row for category-based filtering

Functionality

Method (XML Views)Compose ParameterDescription
setTitle("Notifications")title = "Notifications"Header title text
setShowHeader(true)showHeader = trueToggle header visibility
setShowBackButton(false)showBackButton = falseToggle back button
setShowFilterChips(true)showFilterChips = trueToggle category filter chips
setFeedRequestBuilder(...)feedRequestBuilder = ...Custom feed request
setCategoriesRequestBuilder(...)categoriesRequestBuilder = ...Custom categories request

Custom View Slots

Header View

Replace the entire header:
CometChatNotificationFeed(
    headerView = {
        Row(
            modifier = Modifier.fillMaxWidth().padding(16.dp),
            verticalAlignment = Alignment.CenterVertically
        ) {
            Text("My Notifications", style = CometChatTheme.typography.heading1Bold)
        }
    }
)

State Views

CometChatNotificationFeed(
    emptyStateView = {
        Column(
            modifier = Modifier.fillMaxSize(),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            Text("No notifications yet")
        }
    },
    errorStateView = { exception, onRetry ->
        Column(horizontalAlignment = Alignment.CenterHorizontally) {
            Text("Something went wrong")
            Button(onClick = onRetry) { Text("Retry") }
        }
    },
    loadingStateView = {
        Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
            CircularProgressIndicator()
        }
    }
)

Style

CometChatNotificationFeed(
    style = CometChatNotificationFeedStyle(
        backgroundColor = Color(0xFFF5F5F5),
        headerBackgroundColor = Color.White,
        headerTitleColor = Color(0xFF141414),
        chipActiveBackgroundColor = Color(0xFF3399FF),
        chipActiveTextColor = Color.White,
        chipInactiveBackgroundColor = Color.White,
        chipInactiveTextColor = Color(0xFF727272),
        cardBackgroundColor = Color.White,
        cardBorderColor = Color(0xFFE0E0E0),
        cardBorderRadius = 12.dp,
        unreadIndicatorColor = Color(0xFF3399FF)
    )
)

Style Properties

PropertyDescription
backgroundColorScreen background color
headerBackgroundColorHeader bar background
headerTitleColorHeader title text color
headerBorderColorDivider below header
chipActiveBackgroundColorSelected filter chip background
chipActiveTextColorSelected filter chip text
chipInactiveBackgroundColorUnselected filter chip background
chipInactiveTextColorUnselected filter chip text
chipBorderColorFilter chip border
badgeActiveBackgroundColorActive chip badge background
badgeActiveTextColorActive chip badge text
badgeInactiveBackgroundColorInactive chip badge background
badgeInactiveTextColorInactive chip badge text
timestampTextColorSection header timestamp color
cardBackgroundColorCard container background
cardBorderColorCard container border
cardBorderRadiusCard corner radius
cardBorderWidthCard border width
unreadIndicatorColorUnread dot indicator color
separatorColorSeparator between cards
All colors default to Color.Unspecified (Compose) or 0 (XML) to inherit from CometChatTheme. Override individual values without losing theme support.

ViewModel Access

The component uses CometChatNotificationFeedViewModel from the shared chatuikit-core module. You can provide a custom ViewModel for advanced scenarios:
val viewModel: CometChatNotificationFeedViewModel = viewModel(
    factory = CometChatNotificationFeedViewModelFactory(
        feedRequestBuilder = customBuilder,
        pollingIntervalMs = 60_000L // 1 minute polling
    )
)

CometChatNotificationFeed(
    viewModel = viewModel
)

ViewModel Factory Parameters

ParameterDefaultDescription
feedRequestBuildernullCustom feed request builder
categoriesRequestBuildernullCustom categories request builder
enableListenerstrueEnable WebSocket listeners (false for testing)
pollingIntervalMs30000Unread count polling interval in ms

Common Patterns

Show only unread items

CometChatNotificationFeed(
    feedRequestBuilder = NotificationFeedRequest.NotificationFeedRequestBuilder()
        .setReadState(FeedReadState.UNREAD)
)

Hide filter chips and header

CometChatNotificationFeed(
    showHeader = false,
    showFilterChips = false
)

Custom categories request

CometChatNotificationFeed(
    categoriesRequestBuilder = NotificationCategoriesRequest.NotificationCategoriesRequestBuilder()
        .setLimit(10)
)

Next Steps

Campaigns Feature

Overview of how campaigns work end-to-end

SDK Campaigns API

Low-level SDK APIs for feed items, categories, and engagement

Component Styling

Full styling reference for all components

ViewModel & Data

Custom ViewModels, repositories, and ListOperations