Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Documentation/sources/api-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,78 @@ Messaging.updatePropositionsForSurfaces(surfaces, success -> {
});
```

### updatePropositionsForSurfaces(surfaces, xdm, data, callback)

Dispatches an event for the Edge network extension to fetch personalization decisions from the AJO campaigns for the provided `Surface`s array, attaching optional custom XDM and free-form data fields to the personalization request. The returned decision `Proposition`s are cached in-memory by the Messaging extension.

Any fields provided in `xdm` are merged into the XDM object of the outgoing personalization request. Any fields provided in `data` are merged into the free-form data object of the request. Internal keys required by the SDK — for example, the personalization request `eventType` — always take precedence and cannot be overwritten by the caller.

If provided, `callback` will be called on the Messaging extension's background thread once the response has been fully processed. `true` will be passed to the `callback` if a network response was returned and successfully processed.

To retrieve previously cached decision `Proposition`s, use `getPropositionsForSurfaces` API.

#### Java

##### Syntax

```java
public static void updatePropositionsForSurfaces(@NonNull final List<Surface> surfaces, @Nullable final Map<String, Object> xdm, @Nullable final Map<String, Object> data, @Nullable final AdobeCallback<Boolean> callback)
```

##### Example

#### Kotlin

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

// Custom XDM fields — e.g. context data used by decisioning eligibility rules
val xdmData = mapOf<String, Any>("userTier" to "gold", "loyaltyPoints" to 1200)

// Optional free-form data attached to the request
val freeFormData = mapOf<String, Any>("campaignSource" to "homeScreen")

Messaging.updatePropositionsForSurfaces(surfaces, xdmData, freeFormData) { success ->
if (success) {
// handle success scenario
} else {
// handle error scenario
}
}
```

#### Java

```java
final Surface surface1 = new Surface("myActivity#button");
final Surface surface2 = new Surface("myActivityAttributes");

final List<Surface> surfaces = new ArrayList<>();
surfaces.add(surface1);
surfaces.add(surface2);

// Custom XDM fields — e.g. context data used by decisioning eligibility rules
final Map<String, Object> xdmData = new HashMap<>();
xdmData.put("userTier", "gold");
xdmData.put("loyaltyPoints", 1200);

// Optional free-form data attached to the request
final Map<String, Object> freeFormData = new HashMap<>();
freeFormData.put("campaignSource", "homeScreen");

Messaging.updatePropositionsForSurfaces(surfaces, xdmData, freeFormData, success -> {
if (success) {
// handle success scenario
} else {
// handle error scenario
}
});
```

---

### getPropositionsForSurfaces

Retrieves the previously fetched propositions from the SDK's in-memory propositions cache for the provided surfaces. The callback is invoked with the decision propositions corresponding to the given surfaces or `AdobeError`, if it occurs.
Expand Down
2 changes: 1 addition & 1 deletion code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ org.gradle.caching=true
android.useAndroidX=true

moduleName=messaging
moduleVersion=3.10.0
moduleVersion=3.11.0

#Maven artifact
mavenRepoName=AdobeMobileMessagingSdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Data.AdobeKeys.INAPP_RESPONSE_FORMAT;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Data.AdobeKeys.NAMESPACE;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Data.Value.NEW_IAM;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Inbound.EventType.PERSONALIZATION_REQUEST;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Inbound.EventType.PROPOSITION_FETCH;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Inbound.Key.PERSONALIZATION;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Inbound.Key.QUERY;
import static com.adobe.marketing.mobile.messaging.MessagingConstants.EventDataKeys.Messaging.Inbound.Key.SCHEMAS;
Expand Down Expand Up @@ -140,7 +140,7 @@ Map<String, Object> createExpectedEdgePersonalizationEventData() {
final Map<String, Object> xdmData =
new HashMap<String, Object>() {
{
put(EVENT_TYPE, PERSONALIZATION_REQUEST);
put(EVENT_TYPE, PROPOSITION_FETCH);
}
};
expectedEdgePersonalizationEventData.put(XDM, xdmData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public void testRefreshInAppMessages() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(1, surfacesList.size());
assertEquals("mobileapp://com.adobe.marketing.mobile.messaging.test", surfacesList.get(0));
}
Expand Down Expand Up @@ -562,7 +562,7 @@ public void testUpdatePropositionsForSurfacePaths() throws InterruptedException
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -628,7 +628,7 @@ public void testUpdatePropositionsForSurfacePaths_somePathsInvalid()
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -941,7 +941,7 @@ public void testContentCard_Removal() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public void testContentCard_Qualification() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1206,7 +1206,7 @@ public void testContentCard_Unqualification() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1348,7 +1348,7 @@ public void testContentCard_Requalification() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1530,7 +1530,7 @@ public void testContentCard_Disqualification() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1699,7 +1699,7 @@ public void testContentCardWithoutTriggers_Qualification() throws InterruptedExc
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1809,7 +1809,7 @@ public void testContentCardWithoutTriggers_Unqualification() throws InterruptedE
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -1954,7 +1954,7 @@ public void testContentCardWithoutTriggers_Requalification() throws InterruptedE
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -2128,7 +2128,7 @@ public void testContentCardWithoutTriggers_Disqualification() throws Interrupted
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down Expand Up @@ -2303,7 +2303,7 @@ public void testContentCard_WithIAM() throws InterruptedException {
DataReader.optTypedMap(Object.class, queryDataMap, "personalization", null);
final List<String> surfacesList =
DataReader.optStringList(personalizationDataMap, "surfaces", null);
assertEquals("personalization.request", xdmDataMap.get("eventType"));
assertEquals("decisioning.propositionFetch", xdmDataMap.get("eventType"));
assertEquals(2, surfacesList.size());
assertEquals(
"mobileapp://com.adobe.marketing.mobile.messaging.test/promos/feed1",
Expand Down
Loading
Loading