API Reference
This document provides information on how to use the Messaging APIs to receive content card views in your application.
getContentCardUI
The getContentCardUI
method retrieves a flow of AepUI objects for the provided surface. These AepUI
objects represent templated content cards whose UI can be rendered using provided card composables.
Calling this API will only retrieve the content cards are already downloaded and cached by the Messaging extension. This API will not download content cards from Adobe Journey Optimizer. You must call updatePropositionsForSurfaces
API from the AEPMessaging extension with the desired surfaces prior to calling this API.
Syntax
Kotlin
Copied to your clipboardsuspend fun getContentCardUI(): Flow<List<AepUI<*, *>>>
Example
Kotlin
Copied to your clipboard// Download the content cards for homepage surface using Messaging extensionval surfaces = mutableListOf<Surface>()val surface = Surface("homepage")surfaces.add(surface)Messaging.updatePropositionsForSurfaces(surfaces)// Initialize the ContentCardUIProviderval contentCardUIProvider = ContentCardUIProvider(surface)// get the content cards within a view modelclass MyScreenViewModel : ViewModel {private val contentCardUIProvider = MessagingContentCardProvider(...)private val _aepUIList = MutableStateFlow<List<AepUI<*, *>>>(emptyList())val aepUIList: StateFlow<List<AepUI<*, *>>> = _aepUIList.asStateFlow()// fetch the list of cards when necessaryviewModelScope.launch {contentCardUIProvider.getContentCardUI().collect {aepUi ->_aepUIList.value = aepUi}}}