ContentCardSchemaData

Represents the proposition response object containing a content-card schema.

iOS Interface

@objc(AEPContentCardSchemaData)
@objcMembers
public class ContentCardSchemaData: NSObject, Codable {
    /// Represents the content of the ContentCardSchemaData object.  Its value's type is determined by `contentType`.
    public let content: Any
    
    /// Determines the value type of `content`.
    public let contentType: ContentType
    
    /// Date and time this content card was published represented as epoch seconds
    public let publishedDate: Int?
    
    /// Date and time this content card will expire represented as epoch seconds
    public let expiryDate: Int?
    
    /// Dictionary containing any additional meta data for this content card
    public let meta: [String: Any]?

    ...
}

Public functions

getContentCard - DEPRECATED

data-variant=warning
data-slots=text1, text2
Notice of deprecation
ContentCard class is deprecated as of v5.2.0 (iOS) and will be removed in the next major release of the Messaging extension.

Tries to convert the content of this ContentCardSchemaData into a ContentCard object.

Returns nil if the contentType is not equal to .applicationJson or the data in content is not decodable into a ContentCard.

iOS Swift

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

Syntax

func getContentCard() -> ContentCard?

Example

var propositionItem: PropositionItem
if let contentCardSchemaData = propositionItem.contentCardSchemaData,
   let contentCard = contentCardSchemaData.getContentCard() {
    // do something with the ContentCard object
}

track(_)

Tracks an interaction with the given ContentCardSchemaData.

Parameters

iOS Swift

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

Syntax

public func track(_ interaction: String? = nil, withEdgeEventType eventType: MessagingEdgeEventType)

Example

var contentCardSchemaData: ContentCardSchemaData

// tracking a display
contentCardSchemaData.track(withEdgeEventType: .display)

// tracking a user interaction
contentCardSchemaData.track("itemSelected", withEdgeEventType: .interact)

Android Interface

public class ContentCardSchemaData implements SchemaData {
    private Object content;
    private ContentType contentType;
    private int publishedDate;
    private int expiryDate;
    private Map<String, Object> meta;

    @Override
    public Object getContent() {
        return content;
    }

    public ContentType getContentType() {
        return contentType;
    }

    public int getPublishedDate() {
        return publishedDate;
    }

    public int getExpiryDate() {
        return expiryDate;
    }

    @Nullable public Map<String, Object> getMeta() {
        return meta;
    }

    ...
}

Public functions

getContentCard - DEPRECATED

data-variant=warning
data-slots=text1, text2
Notice of deprecation
ContentCard class is deprecated as of v3.2.0 (Android) and will be removed in the next major release of the Messaging extension.

Tries to convert the content of this ContentCardSchemaData into a ContentCard object.

Returns null if the contentType is not equal to ContentType.APPLICATION_JSON or the data in content is not decodable into a ContentCard.

Android Java

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

Syntax

@Nullable public ContentCard getContentCard();

Example

PropositionItem propositionItem;
ContentCardSchemaData contentCardSchemaData = propositionItem.getContentCardSchemaData();
ContentCard contentCard = contentCardSchemaData.getContentCard();
if (contentCard != null) {
  // do something with the ContentCard object
}

Android Kotlin

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

Example

val propisitionItem: PropositionItem
val contentCardData = item?.contentCardSchemaData
val contentCard = contentCardData?.contentCard
contentCard?.let {
  // do something with the ContentCard object
}

track

Tracks an interaction with the given ContentCardSchemaData.

Parameters

Android Java

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

Syntax

public void track(final String interaction, final MessagingEdgeEventType eventType);

Example

ContentCardSchemaData contentCardSchemaData;

// tracking a display
contentCardSchemaData.track(null, MessagingEdgeEventType.DISPLAY);

// tracking a user interaction
contentCardSchemaData.track("itemSelected", MessagingEdgeEventType.INTERACT);

Android Kotlin

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

Example

val contentCardSchemaData = item?.contentCardSchemaData

// tracking a display
contentCardSchemaData?.track(null, MessagingEdgeEventType.DISPLAY)

// tracking a user interaction
contentCardSchemaData?.track("itemSelected", MessagingEdgeEventType.INTERACT)