Before using the SDK, set up your channels, categories, templates, and campaigns in the CometChat Dashboard. See the Dashboard Setup Guide for step-by-step instructions.
Key Concepts
Card Messages
A Card Message is a structured, interactive message rendered as a card bubble inside a conversation. Cards are receive-only on the SDK: they are created through the Platform REST API or the Dashboard Bubble Builder and delivered to clients like any other message — the SDK does not send them.- Type:
com.cometchat.chat.models.CardMessage - Category:
"card"(CometChatConstants.CATEGORY_CARD)
Properties
Listening for card messages
To be notified when a card message arrives, implementonCardMessageReceived on your MessageListener.
- Java
- Kotlin
MessageListener reference.
Rendering Cards
Thecontent field of each NotificationFeedItem is a Card Schema JSON object. To render it natively, use the CometChat Cards library.
Add the Cards Dependency
Add the Cloudsmith repository and the cards library to your project:Requires
minSdk 24, Kotlin, and internet permission in your AndroidManifest.xml.Render a Card from a Feed Item
- Jetpack Compose
- Traditional View
The Cards library is a pure renderer — it does not execute actions. Your code must handle action callbacks (opening URLs, navigating to chats, making API calls, etc.).
How Cards Render in the Notification Feed
EachNotificationFeedItem has a content field containing a JSONObject — this is the Card Schema JSON. This JSON is passed directly to the CometChat Cards renderer library (com.cometchat:cards-android).
The rendering flow:
- Fetch feed items via
NotificationFeedRequest - For each item, extract
item.getContent()— this is the Card Schema JSON - Convert to string:
item.getContent().toString() - Pass to the Cards renderer (
CometChatCardVieworCometChatCardComposable) - The renderer produces a native Android view from the JSON
Card Schema JSON Structure
body array contains elements (text, image, button, row, column, etc.) rendered top-to-bottom. Interactive elements like buttons emit actions via a callback — the consumer handles navigation, deep links, or API calls.
Retrieve Notification Feed Items
UseNotificationFeedRequest to fetch a paginated list of feed items. Uses cursor-based pagination internally.
Build the Request
- Java
- Kotlin
Builder Parameters
Fetch Items
- Java
- Kotlin
fetchNext() repeatedly for pagination. When the server has no more items, subsequent calls return an empty list.
NotificationFeedItem Fields
Retrieve Notification Categories
UseNotificationCategoriesRequest to fetch available categories for filter chips.
- Java
- Kotlin
NotificationCategory Fields
Real-Time Notification Feed Listener
Listen for new feed items arriving via WebSocket. This listener is independent fromMessageListener, GroupListener, and CallListener.
- Java
- Kotlin
- Java
- Kotlin
Mark Feed Item as Read
Mark a single item as read. Idempotent — safe to call multiple times.- Java
- Kotlin
Mark Feed Item as Delivered
Mark a single item as delivered. Idempotent.- Java
- Kotlin
Report Engagement
Report that a user engaged with a feed item (e.g., viewed, clicked, interacted). Idempotent.- Java
- Kotlin
interactionString parameter is a free-form string describing the engagement (e.g., "viewed", "clicked", "interacted").
Get Unread Count
Fetch the total number of unread notification feed items.- Java
- Kotlin
Fetch Single Feed Item
Fetch a specific item by ID — useful for deep linking from push notifications.- Java
- Kotlin
Push Notification Tracking
When a campaign push notification arrives via FCM, use these methods to report delivery and click engagement.Mark Push Notification as Delivered
Call this in yourFirebaseMessagingService.onMessageReceived():
- Java
- Kotlin
Mark Push Notification as Clicked
Call this when the user taps the push notification:- Java
- Kotlin