MessagingInboxProvider
Messaging extension implementation of AepInboxContentProvider. MessagingInboxProvider is responsible for fetching the Inbox content for a given surface and managing the Inbox state through reactive updates when the content needs to be refreshed.
Constructor
Copied to your clipboardMessagingInboxProvider(surface: Surface)
Parameters
| Parameter | Type | Description |
|---|---|---|
surface | The surface to fetch inbox content for. |
Methods
getInboxUI
Retrieves the Inbox content and updates the state as a flow. This method automatically loads initial content when first collected.
Returns
A Flow of InboxUIState representing the current state of the inbox.
Syntax
Copied to your clipboardoverride fun getInboxUI(): Flow<InboxUIState>
refresh
Refreshes the Inbox content by fetching new inbox and content cards propositions from the device cache and updating the flow returned by getInboxUI. This will cause all collectors of the flow to receive the updated inbox.
Emits InboxUIState.Loading before fetching, then emits InboxUIState.Success or InboxUIState.Error.
getInboxUI automatically loads initial content when first collected, so you only need refresh for manual refresh (for example after updatePropositionsForSurfaces).
Syntax
Copied to your clipboardoverride suspend fun refresh()
Usage Example
Copied to your clipboardclass InboxViewModel : ViewModel() {private val inboxProvider = MessagingInboxProvider(Surface("inbox"))val inboxUIState: StateFlow<InboxUIState> = inboxProvider.getInboxUI().stateIn(scope = viewModelScope,started = SharingStarted.WhileSubscribed(5000),initialValue = InboxUIState.Loading)fun refresh() {viewModelScope.launch {inboxProvider.refresh()}}}
