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:
- surface - The Surface for which the content cards should be retrieved.
- customizer - An optional ContentCardCustomizing object to customize the appearance of the content card template. If you do not need to customize the appearance of the content card template, this parameter can be omitted.
- listener - An optional ContentCardUIEventListening object to listen to UI events from the content card. If you do not need to listen to UI events from the content card, this parameter can be omitted.
- completion - A completion handler that is called with a
Result
containing either:- success - An array of ContentCardUI objects representing the content cards to be displayed.
- failure - An
Error
object indicating the reason for the failure, if any.
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
Swift
Copied to your clipboardpublic static func getContentCardsUI(for surface: Surface,customizer: ContentCardCustomizing? = nil,listener: ContentCardUIEventListening? = nil,_ completion: @escaping (Result<[ContentCardUI], Error>) -> Void)
Example
Swift
Copied to your clipboard// Download the content cards for homepage surface using Messaging extensionlet homePageSurface = Surface(path: "homepage")Messaging.updatePropositionsForSurfaces([homePageSurface])// Get the content card UI for the homepage surfaceMessaging.getContentCardsUI(for: homePageSurface) { result inswitch result {case .success(let contentCards):// Use the contentCards array to display UI for templated content cards in your applicationcase .failure(let error):// Handle the error}}