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
    }
}