Self-handled cards give you the flexibility of creating Card Campaigns on the MoEngage Platform and displaying the cards anywhere inside the application. SDK provides APIs to fetch the campaign’s data using which you can create your own view for cards.Documentation Index
Fetch the complete documentation index at: https://moengage-sdk-docs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
SDK Installation
Installing using BOM
Integration using BOM is the recommended way of integration; refer to the Install Using BOM document. Once you have configured the BOM add the dependency in the app/build.gradle file as shown belowNote: Version numbers are not required for these dependencies; the BOM automatically manages them.
Implementing Self Handled Cards
Use the below APIs to fetch the card’s data and build your own UI. The SDK provides both blocking and async APIs for fetching the data. In this document, we have just added the blocking APIs, refer to the API reference for MoECardHelper for the async APIs.Notify on Section Load/Unload
You can show the cards on a separate screen or a section of the screen. When the cards screen/section is loaded call onCardSectionLoaded() and call onCardSectionUnloaded() when the screen/section is no longer visible or going to background.- When onCardSectionLoaded() and onCardSectionUnloaded() are called together, the SDK automatically tracks the card impressions.
- The onCardSectionLoaded() has an SLA of 5 minutes.
Fetch Cards from the Server
Use the fetchCards() API to refresh cards from the MoEngage server.fetchCards() hits the server at most once every 5 minutes. If called more frequently, the existing cached cards are returned via the callback.
Refresh Cards
Checks the server for card updates. Returns ahasUpdates flag. If hasUpdates is true, the latest cards are stored in local storage. Call getCards() / getCardsForCategory() / getCardsInfo() to retrieve the updated cards from local storage.
Method signature: MoECardHelper.refreshCards(context, listener)
refreshCards() has a shorter SLA (~5 seconds) compared to fetchCards() (5 minutes), making it suitable for near-real-time card updates.
Fetch Categories
To fetch all the categories for which cards are configured, use the getCardCategories() API.Fetch Cards for Categories
To fetch cards eligible for display for a specific category, use the getCardsForCategory() APIWidget and Widget Id Mapping
Basic Card/Illustration Card
| Widget Id | Widget Type | Widget Information |
|---|---|---|
| 0 | Image (WidgetType.IMAGE) | Image widget in the card. |
| 1 | Text (WidgetType.TEXT) | Header text for the card. |
| 2 | Text (WidgetType.TEXT) | Message text for the card. |
| 3 | Button (WidgetType.Button) | Call to action(CTA) for the card. |
Track Statistics for Cards
Since the UI/display of the cards is controlled by the application to track statistics on delivery, display, and click, we need the application to notify the SDK.Delivered
To track delivery to the card section of the application, call the cardDelivered() API when the cards section of the application is loaded.Impression
Call the cardShown() API when a specific card is visible on the screen.Click
Call the cardClicked() API whenever a user clicks on a card, along with the card object widget identifier for the UI element clicked should also be passed.Delete Card
Call the deleteCard() API to delete a cardFAQs
What is the recommended implementation for a standard Cards Inbox?
What is the recommended implementation for a standard Cards Inbox?
MoEngage recommends calling onCardSectionLoaded() when the user enters the Cards section and onCardSectionUnloaded() when they leave. Doing so allows the SDK to automatically handle server synchronization, event deduplication, and impression tracking.
How do I handle near-real-time card updates (e.g., replacing a card after a user action)
How do I handle near-real-time card updates (e.g., replacing a card after a user action)
Follow this 3-step pattern to ensure cards are always fresh without hitting rate limits:
- Initial Load: On page load, call
fetchCards()to get the latest cards from the server. - Trigger Update: When you need to check for updates (e.g., after a survey submission), call
refreshCards(). - Retrieve Data: If
refreshCards()returnshasUpdates = true, callgetCardsForCategory()orgetCardsInfo()to pull the updated cards from local storage.
What is the difference between onCardSectionLoaded() and fetchCards()?
What is the difference between onCardSectionLoaded() and fetchCards()?
| Feature | onCardSectionLoaded() + onCardSectionUnLoaded() | fetchCards() |
|---|---|---|
| Use Case | Recommended for card inbox screens. | One-time refresh outside the section lifecycle. |
| Impression Tracking | The SDK tracks card impressions automatically. | User have to track impressions Manually |