Skip to content

Commit

Permalink
Merge pull request #635 from AdobeDocs/content-cards
Browse files Browse the repository at this point in the history
merge docs for content cards to main
  • Loading branch information
sbenedicadb authored Jun 26, 2024
2 parents 6a4e057 + 31103b2 commit 4b52dac
Show file tree
Hide file tree
Showing 17 changed files with 956 additions and 62 deletions.
36 changes: 30 additions & 6 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ module.exports = {
]
},
{
title: "Code-based Experiences",
title: "Code-based Experiences & Content Cards",
path: "/edge/adobe-journey-optimizer/code-based",
pages: [
{
title: "API reference",
path: "/edge/adobe-journey-optimizer/code-based/api-reference"
},
{
title: "Tutorial",
title: "Code-based Tutorial",
path: "/edge/adobe-journey-optimizer/code-based/tutorial"
}
]
Expand All @@ -258,12 +258,28 @@ module.exports = {
path: "/edge/adobe-journey-optimizer/public-classes",
pages: [
{
title: "MessagingPushPayload",
path: "/edge/adobe-journey-optimizer/public-classes/messaging-push-payload"
title: "ContentCard",
path: "/edge/adobe-journey-optimizer/public-classes/content-card"
},
{
title: "PushTrackingStatus",
path: "/edge/adobe-journey-optimizer/public-classes/push-tracking-status"
title: "ContentCardSchemaData",
path: "/edge/adobe-journey-optimizer/public-classes/content-card-schema-data"
},
{
title: "ContentType",
path: "/edge/adobe-journey-optimizer/public-classes/content-type"
},
{
title: "HtmlContentSchemaData",
path: "/edge/adobe-journey-optimizer/public-classes/html-content-schema-data"
},
{
title: "InAppSchemaData",
path: "/edge/adobe-journey-optimizer/public-classes/inapp-schema-data"
},
{
title: "JsonContentSchemaData",
path: "/edge/adobe-journey-optimizer/public-classes/json-content-schema-data"
},
{
title: "Message",
Expand All @@ -273,6 +289,10 @@ module.exports = {
title: "MessagingEdgeEventType",
path: "/edge/adobe-journey-optimizer/public-classes/messaging-edge-event-type"
},
{
title: "MessagingPushPayload",
path: "/edge/adobe-journey-optimizer/public-classes/messaging-push-payload"
},
{
title: "Proposition",
path: "/edge/adobe-journey-optimizer/public-classes/proposition"
Expand All @@ -281,6 +301,10 @@ module.exports = {
title: "PropositionItem",
path: "/edge/adobe-journey-optimizer/public-classes/proposition-item"
},
{
title: "PushTrackingStatus",
path: "/edge/adobe-journey-optimizer/public-classes/push-tracking-status"
},
{
title: "Surface",
path: "/edge/adobe-journey-optimizer/public-classes/surface"
Expand Down
13 changes: 9 additions & 4 deletions src/pages/edge/adobe-journey-optimizer/code-based/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ This document guides you to integrating code-based experiences in your applicati

## Public Classes and Enums

* [Class - Proposition](../public-classes/proposition.md)
* [Class - PropositionItem](../public-classes/proposition-item.md)
* [Enum - MessagingEdgeEventType](../public-classes/messaging-edge-event-type.md)
* [Class - Surface](../public-classes/surface.md)
* [Class - ContentCard](./../public-classes/content-card.md)
* [Class - Proposition](./../public-classes/proposition.md)
* [Class - PropositionItem](./../public-classes/proposition-item.md)
* [Class - Surface](./../public-classes/surface.md)
* [Enum - MessagingEdgeEventType](./../public-classes/messaging-edge-event-type.md)
* [Schema Class - ContentCardSchemaData](./../public-classes/content-card-schema-data.md)
* [Schema Class - HtmlContentSchemaData](./../public-classes/html-content-schema-data.md)
* [Schema Class - InAppSchemaData](./../public-classes/inapp-schema-data.md)
* [Schema Class - JsonContentSchemaData](./../public-classes/json-content-schema-data.md)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
noIndex: true
---

<Variant platform="android" api="get-propositions-for-surfaces" repeat="6"/>
<Variant platform="android" api="get-propositions-for-surfaces" repeat="9"/>

#### Java

Expand All @@ -15,7 +15,31 @@ public static void getPropositionsForSurfaces(@NonNull final List<Surface> surfa
* _surfaces_ is a list of surfaces for which propositions are requested.
* _callback_ `call` method is invoked with propositions map of type `Map<Surface, List<Proposition>>`. If the callback is an instance of [AdobeCallbackWithError](../../../../home/base/mobile-core/api-reference.md#adobecallbackwitherror), and if the operation times out or an error occurs in retrieving propositions, the `fail` method is invoked with the appropriate [AdobeError](../../../../home/base/mobile-core/api-reference.md#adobeerror).

**Syntax**
**Example**

#### Kotlin

```kotlin
val surface1 = Surface("myActivity#button")
val surface2 = Surface("myActivityAttributes")
val surfaces = listOf(surface1, surface2)

Messaging.getPropositionsForSurfaces(surfaces) {
it?.let { propositionsMap ->
if (propositionsMap.isNotEmpty()) {
// get the propositions for the given surfaces
propositionsMap[surface1]?.let {
// read surface1 propositions
}
propositionsMap[surface2]?.let {
// read surface2 propositions
}
}
}
}
```

#### Java

```java
final Surface surface1 = new Surface("myActivity#button");
Expand Down Expand Up @@ -61,7 +85,7 @@ static func getPropositionsForSurfaces(_ surfacePaths: [Surface], _ completion:
* _surfaces_ is an array of surfaces for which propositions are requested.
* _completion_ is invoked with propositions dictionary of type `[Surface: [Proposition]]`. An `Error` is returned if SDK fails to retrieve the propositions.

**Syntax**
**Example**

```swift
let surface1 = Surface(path: "myView#button")
Expand Down Expand Up @@ -101,7 +125,7 @@ Messaging.getPropositionsForSurfaces([surface1, surface2]) { propositionsDict, e
* _surfaces_ is an array of surfaces for which propositions are requested.
* _completion_ is invoked with propositions dictionary of type `NSDictionary<AEPSurface*, NSArray<AEPProposition*>*>`. An `NSError` is returned if SDK fails to retrieve the propositions.

**Syntax**
**Example**

```objc
AEPSurface* surface1 = [[AEPSurface alloc] initWithPath: @"myView#button"];
Expand All @@ -122,7 +146,7 @@ AEPSurface* surface2 = [[AEPSurface alloc] initWithPath: @"myView#button"];
}];
```
<Variant platform="android" api="update-propositions-for-surfaces" repeat="6"/>
<Variant platform="android" api="update-propositions-for-surfaces" repeat="9"/>
#### Java
Expand All @@ -134,7 +158,19 @@ public static void updatePropositionsForSurfaces(@NonNull final List<Surface> su

* _surfaces_ is a list of surfaces for which propositions need updating.

**Syntax**
**Example**

#### Kotlin

```kotlin
val surface1 = Surface("myActivity#button")
val surface2 = Surface("myActivityAttributes")
val surfaces = listOf(surface1, surface2)

Messaging.updatePropositionsForSurfaces(surfaces)
```

#### Java

```java
final Surface surface1 = new Surface("myActivity#button");
Expand All @@ -159,7 +195,7 @@ static func updatePropositionsForSurfaces(_ surfaces: [Surface])

* _surfaces_ is an array of surfaces for which propositions need updating.

**Syntax**
**Example**

```swift
let surface1 = Surface(path: "myView#button")
Expand All @@ -178,7 +214,7 @@ Messaging.updatePropositionsForSurfaces([surface1, surface2])

* _surfaces_ is an array of surfaces for which propositions need updating.

**Syntax**
**Example**

```objc
AEPSurface* surface1 = [[AEPSurface alloc] initWithPath: @"myView#button"];
Expand Down
84 changes: 79 additions & 5 deletions src/pages/edge/adobe-journey-optimizer/code-based/tabs/tutorial.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<Variant platform="android" function="updatepropositionsforsurfaces" repeat="2"/>
<Variant platform="android" function="updatepropositionsforsurfaces" repeat="4"/>

#### Kotlin

```kotlin
val surface1 = Surface("mainActivity#banner")
val surface2 = Surface("secondActivity#promotions")
val surfaces = listOf(surface1, surface2)

// fetch propositions from server and cache in-memory
Messaging.updatePropositionsForSurfaces(surfaces)
```

#### Java

Expand Down Expand Up @@ -26,7 +37,29 @@ let surface2 = Surface("secondActivity#promotions")
Messaging.updatePropositionsForSurfaces([surface1, surface2])
```

<Variant platform="android" function="getpropositionsforsurfaces" repeat="2"/>
<Variant platform="android" function="getpropositionsforsurfaces" repeat="4"/>

#### Kotlin

```kotlin
val surface1 = Surface("mainActivity#banner")
val surface2 = Surface("secondActivity#promotions")
val surfaces = listOf(surface1, surface2)

Messaging.getPropositionsForSurfaces(surfaces) {
it?.let { propositionsMap ->
if (propositionsMap.isNotEmpty()) {
// get the propositions for the given surfaces
propositionsMap[surface1]?.let {
// read surface1 propositions
}
propositionsMap[surface2]?.let {
// read surface2 propositions
}
}
}
}
```

#### Java

Expand Down Expand Up @@ -91,7 +124,25 @@ Messaging.getPropositionsForSurfaces([surface1, surface2]) { propositionsDict, e
}
```

<Variant platform="android" function="using-propositions" repeat="2"/>
<Variant platform="android" function="using-propositions" repeat="4"/>

#### Kotlin

```kotlin
// get the propositions for surface1
// bail early if no propositions are found for surface1
if (propositionsForSurface1 == null || propositionsForSurface1.isEmpty()) return

// iterate through items in proposition
for (propositionItem in propositionsForSurface1.first()::items) {
if (propositionItem.schema == SchemaType.HTML_CONTENT) {
// retrieve the HTML content
val htmlContent = propositionItem.htmlContent

// use retrieved html content
}
}
```

#### Java

Expand Down Expand Up @@ -132,7 +183,19 @@ if let codePropositions: [Proposition] = propositionsDict?[surface1], !codePropo
}
```

<Variant platform="android" function="track" repeat="2"/>
<Variant platform="android" function="track" repeat="4"/>

#### Kotlin

```kotlin
// Tracking display of PropositionItem
// use the same propositionItem object that was used to get the content in the previous section
propositionItem.track(MessagingEdgeEventType.DISPLAY)

// Tracking interaction with PropositionItem
// use the same propositionItem object that was used to get the content in the previous section
propositionItem.track("click", MessagingEdgeEventType.INTERACT, null)
```

#### Java

Expand Down Expand Up @@ -160,7 +223,18 @@ propositionItem.track(withEdgeEventType: MessagingEdgeEventType.display)
propositionItem.track("click", withEdgeEventType: MessagingEdgeEventType.display)
```

<Variant platform="android" function="track-with-tokens" repeat="2"/>
<Variant platform="android" function="track-with-tokens" repeat="4"/>

#### Kotlin

```kotlin
// Tracking interaction with PropositionItem with tokens
// Extract the tokens from the PropositionItem item data
val tokenList = mutableListOf<String>()
tokenList += dataItemToken1
tokenList += dataItemToken2
propositionItem.track("click", MessagingEdgeEventType.INTERACT, tokenList)
```

#### Java

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This document describes how to fetch, display and track code-based experiences u

## Pre-requisites

[Integrate and register Messaging extension](../index.md#implement-extension-in-mobile-app) in your app.
[Integrate and register Messaging extension](../../index.md#implement-extension-in-mobile-app) in your app.

## Fetch and cache the code-based content

Expand Down
Loading

0 comments on commit 4b52dac

Please sign in to comment.