API Reference
This document provides information on how to use the Messaging APIs to receive and display content card views in your application.
getContentCardUIFlow
The getContentCardUIFlow method returns a cold Flow of AepUI objects for the provided surface. These AepUI objects represent templated content cards whose UI can be rendered using provided card composables. Content is fetched lazily when the flow is collected.
data-variant=info
data-slots=text
Calling this API will not download content cards from Adobe Journey Optimizer; it will only retrieve the content cards that are already downloaded and cached by the Messaging extension. You must call
updatePropositionsForSurfaces API from the AEPMessaging extension with the desired surfaces prior to calling this API.Syntax
data-slots=heading, code
data-repeat=1
data-languages=Kotlin
Kotlin
fun getContentCardUIFlow(): Flow<Result<List<AepUI<*, *>>>>
Example
data-slots=heading, code
data-repeat=1
data-languages=Kotlin
Kotlin
// Download the content cards for homepage surface using Messaging extension
val surfaces = mutableListOf<Surface>()
val surface = Surface("homepage")
surfaces.add(surface)
Messaging.updatePropositionsForSurfaces(surfaces)
// Initialize the ContentCardUIProvider
val contentCardUIProvider = ContentCardUIProvider(surface)
// get the content cards within a view model
class MyScreenViewModel : ViewModel() {
private val contentCardUIProvider = ContentCardUIProvider(surface)
private val _aepUIList = MutableStateFlow<List<AepUI<*, *>>>(emptyList())
val aepUIList: StateFlow<List<AepUI<*, *>>> = _aepUIList.asStateFlow()
// Obtain the flow without a coroutine context, then collect it
val contentCardFlow = contentCardUIProvider.getContentCardUIFlow()
init {
viewModelScope.launch {
contentCardFlow.collect { result ->
result.onSuccess { aepUi -> _aepUIList.value = aepUi }
}
}
}
}
getContentCardUI (Deprecated)
The getContentCardUI suspend function is retained for binary compatibility with apps built against earlier releases. It eagerly fetches content before returning the flow and requires a coroutine call site to obtain the flow reference.
Syntax
data-slots=heading, code
data-repeat=1
data-languages=Kotlin
Kotlin
@Deprecated("Use getContentCardUIFlow() instead.")
suspend fun getContentCardUI(): Flow<Result<List<AepUI<*, *>>>>