API Reference

This document lists the public APIs available in the Messaging extension for implementing content card with UI.

getContentCardsUI

The getContentCardsUI method retrieves an array of ContentCardUI objects for the provided surface. These ContentCardUI objects provide the user interface for templated content cards to your application.

Parameters

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 the updatePropositionsForSurfaces API with the desired surfaces prior to calling this API.

Syntax

data-slots=heading, code
data-repeat=1

Swift

public static func getContentCardsUI(for surface: Surface,
                                     customizer: ContentCardCustomizing? = nil,
                                     listener: ContentCardUIEventListening? = nil,
                                     _ completion: @escaping (Result<[ContentCardUI], Error>) -> Void)

Example

data-slots=heading, code
data-repeat=1

Swift

// Download the content cards for homepage surface using Messaging extension
let homePageSurface = Surface(path: "homepage")
Messaging.updatePropositionsForSurfaces([homePageSurface])

// Get the content card UI for the homepage surface
Messaging.getContentCardsUI(for: homePageSurface) { result in
    switch result {
    case .success(let contentCards):
        // Use the contentCards array to display UI for templated content cards in your application
    case .failure(let error):
        // Handle the error
    }
}

clearCachedPropositions

Clears all downloaded and cached content card propositions from both the in-memory cache and on-device storage. Call this API when a user signs out or when you need to ensure no persisted content card data carries forward to the next session.

data-variant=info
data-slots=text
This API only affects content card propositions. In-App Message rules and other extension data are not affected. See Offline Content Card Availability for more details on the persistence feature.

Syntax

data-slots=heading, code
data-repeat=1

Swift

public static func clearCachedPropositions()

Example

data-slots=heading, code
data-repeat=1

Swift

Messaging.clearCachedPropositions()