Skip to content

Commit

Permalink
Merge pull request #562 from AdobeDocs/migration-android
Browse files Browse the repository at this point in the history
Merge android migration docs to main
  • Loading branch information
praveek authored Apr 5, 2024
2 parents 55e83c2 + d4bb49b commit 236bb19
Show file tree
Hide file tree
Showing 33 changed files with 916 additions and 220 deletions.
5 changes: 4 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ module.exports = {
path: "/edge/adobe-journey-optimizer/in-app-message/tutorials/messaging-delegate",
pages: [
{
title: "Progrmmatically control the display of in-app messages",
title: "Programmatically control the display of in-app messages",
path: "/edge/adobe-journey-optimizer/in-app-message/tutorials/messaging-delegate"
},
{
Expand Down Expand Up @@ -829,6 +829,9 @@ module.exports = {
title: "Android",
path: "/resources/migration/android",
pages: [{
title: "Migrate to 3.x SDKs",
path: "/resources/migration/android/migrate-to-3x"
},{
title: "Migrate to 2.x SDKs",
path: "/resources/migration/android/migrate-to-2x"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ iOS

<Tabs query="platform=ios&api=decisionscope"/>

### Proposition/OptimizeProposition
### OptimizeProposition

This class represents the decision propositions received from the decisioning services, upon a personalization query request to the Experience Edge network.

<InlineAlert variant="warning" slots="text"/>

In SDK versions lower than Android 3.0.0 and iOS 5.0.0, this class was named `Proposition`

<TabsBlock orientation="horizontal" slots="heading, content" repeat="2"/>

Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ NSString *extensionVersion = [AEPMobileOptimize extensionVersion];
#### Syntax

```java
public static void getPropositions(final List<DecisionScope> decisionScopes, final AdobeCallback<Map<DecisionScope, Proposition>> callback)
public static void getPropositions(final List<DecisionScope> decisionScopes, final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
```

* _decisionScopes_ is a list of decision scopes for which propositions are requested.
* _callback_ `call` method is invoked with propositions map of type `Map<DecisionScope, 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).
* _callback_ `call` method is invoked with propositions map of type `Map<DecisionScope, OptimizeProposition>`. 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).

#### Example

Expand All @@ -117,22 +117,22 @@ final List<DecisionScope> decisionScopes = new ArrayList<>();
decisionScopes.add(decisionScope1);
decisionScopes.add(decisionScope2);

Optimize.getPropositions(scopes, new AdobeCallbackWithError<Map<DecisionScope, Proposition>>() {
Optimize.getPropositions(scopes, new AdobeCallbackWithError<Map<DecisionScope, OptimizeProposition>>() {
@Override
public void fail(final AdobeError adobeError) {
// handle error
}

@Override
public void call(Map<DecisionScope, Proposition> propositionsMap) {
public void call(Map<DecisionScope, OptimizeProposition> propositionsMap) {
if (propositionsMap != null && !propositionsMap.isEmpty()) {
// get the propositions for the given decision scopes
if (propositionsMap.contains(decisionScope1)) {
final Proposition proposition1 = propsMap.get(decisionScope1)
final OptimizeProposition proposition1 = propsMap.get(decisionScope1)
// read proposition1 offers
}
if (propositionsMap.contains(decisionScope2)) {
final Proposition proposition2 = propsMap.get(decisionScope2)
final OptimizeProposition proposition2 = propsMap.get(decisionScope2)
// read proposition2 offers
}
}
Expand Down Expand Up @@ -225,22 +225,22 @@ AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myS
#### Syntax
```java
public static void onPropositionsUpdate(final AdobeCallback<Map<DecisionScope, Proposition>> callback)
public static void onPropositionsUpdate(final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
```

* _callback_ `call` method is invoked with propositions map of type `Map<DecisionScope, Proposition>`. If the callback is an instance of `AdobeCallbackWithError`, and if the operation times out or an error occurs in retrieving propositions, the `fail` method is invoked with the appropriate `AdobeError`.
* _callback_ `call` method is invoked with propositions map of type `Map<DecisionScope, OptimizeProposition>`. If the callback is an instance of `AdobeCallbackWithError`, and if the operation times out or an error occurs in retrieving propositions, the `fail` method is invoked with the appropriate `AdobeError`.

#### Example

```java
Optimize.onPropositionsUpdate(new AdobeCallbackWithError<Map<DecisionScope, Proposition>>() {
Optimize.onPropositionsUpdate(new AdobeCallbackWithError<Map<DecisionScope, OptimizeProposition>>() {
@Override
public void fail(final AdobeError adobeError) {
// handle error
}

@Override
public void call(final Map<DecisionScope, Proposition> propositionsMap) {
public void call(final Map<DecisionScope, OptimizeProposition> propositionsMap) {
if (propositionsMap != null && !propositionsMap.isEmpty()) {
// handle propositions
}
Expand Down Expand Up @@ -482,52 +482,52 @@ public class DecisionScope: NSObject, Codable {
#### Java

```java
public class Proposition {
public class OptimizeProposition {

/**
* Constructor creates a {@code Proposition} using the provided propostion {@code id}, {@code offers}, {@code scope} and {@code scopeDetails}.
* Constructor creates a {@code OptimizeProposition} using the provided propostion {@code id}, {@code offers}, {@code scope} and {@code scopeDetails}.
*
* @param id {@link String} containing proposition identifier.
* @param offers {@code List<Offer>} containing proposition items.
* @param scope {@code String} containing encoded scope.
* @param scopeDetails {@code Map<String, Object>} containing scope details.
*/
Proposition(final String id, final List<Offer> offers, final String scope, final Map<String, Object> scopeDetails) {...}
OptimizeProposition(final String id, final List<Offer> offers, final String scope, final Map<String, Object> scopeDetails) {...}

/**
* Gets the {@code Proposition} identifier.
* Gets the {@code OptimizeProposition} identifier.
*
* @return {@link String} containing the {@link Proposition} identifier.
* @return {@link String} containing the {@link OptimizeProposition} identifier.
*/
public String getId() {...}

/**
* Gets the {@code Proposition} items.
* Gets the {@code OptimizeProposition} items.
*
* @return {@code List<Offer>} containing the {@link Proposition} items.
* @return {@code List<Offer>} containing the {@link OptimizeProposition} items.
*/
public List<Offer> getOffers() {...}

/**
* Gets the {@code Proposition} scope.
* Gets the {@code OptimizeProposition} scope.
*
* @return {@link String} containing the encoded {@link Proposition} scope.
* @return {@link String} containing the encoded {@link OptimizeProposition} scope.
*/
public String getScope() {...}

/**
* Gets the {@code Proposition} scope details.
* Gets the {@code OptimizeProposition} scope details.
*
* @return {@code Map<String, Object>} containing the {@link Proposition} scope details.
* @return {@code Map<String, Object>} containing the {@link OptimizeProposition} scope details.
*/
public Map<String, Object> getScopeDetails() {...}

/**
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Reference} field group from this {@code Proposition}.
* Generates a map containing XDM formatted data for {@code Experience Event - OptimizeProposition Reference} field group from this {@code OptimizeProposition}.
*
* The returned XDM data does not contain {@code eventType} for the Experience Event.
*
* @return {@code Map<String, Object>} containing the XDM data for the proposition reference.
* @return {@code Map<String, Object>} containing the XDM data for the OptimizeProposition reference.
*/
public Map<String, Object> generateReferenceXdm() {...}
}
Expand Down Expand Up @@ -722,26 +722,26 @@ public class Offer {
public Map<String, String> getCharacteristics() {...}

/**
* Gets the containing {@code Proposition} for this {@code Offer}.
* Gets the containing {@code OptimizeProposition} for this {@code Offer}.
*
* @return {@link Proposition} instance.
* @return {@link OptimizeProposition} instance.
*/
public Proposition getProposition() {...}
public OptimizeProposition getProposition() {...}

/**
* Dispatches an event for the Edge network extension to send an Experience Event to the Edge network with the display interaction data for the
* given {@code Proposition} offer.
* given {@code OptimizeProposition} offer.
*/
public void displayed() {...}

/**
* Dispatches an event for the Edge network extension to send an Experience Event to the Edge network with the tap interaction data for the
* given {@code Proposition} offer.
* given {@code OptimizeProposition} offer.
*/
public void tapped() {...}

/**
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code Proposition} item.
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code OptimizeProposition} item.
*
* The returned XDM data does contain the {@code eventType} for the Experience Event with value {@code decisioning.propositionDisplay}.
*
Expand All @@ -753,7 +753,7 @@ public class Offer {
public Map<String, Object> generateDisplayInteractionXdm() {...}

/**
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code Proposition} offer.
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code OptimizeProposition} offer.
*
* The returned XDM data contains the {@code eventType} for the Experience Event with value {@code decisioning.propositionInteract}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
noIndex: true
---

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

### Coming soon

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

#### Java
Expand Down Expand Up @@ -52,7 +47,6 @@ Messaging.getPropositionsForSurfaces(surfaces, new AdobeCallbackWithError<Map<Su
}
});
```
-->

<Variant platform="ios" api="get-propositions-for-surfaces" repeat="12"/>

Expand Down Expand Up @@ -128,11 +122,6 @@ AEPSurface* surface2 = [[AEPSurface alloc] initWithPath: @"myView#button"];
}];
```
<Variant platform="android" api="update-propositions-for-surfaces" repeat="1"/>
### Coming soon
<!--
<Variant platform="android" api="update-propositions-for-surfaces" repeat="6"/>
#### Java
Expand All @@ -157,7 +146,6 @@ surfaces.add(surface2);

Messaging.updatePropositionsForSurfaces(surfaces)
```
-->

<Variant platform="ios" api="update-propositions-for-surfaces" repeat="12"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ keywords:
- JavaScript event
- Messaging
- Messaging delegate
- PresentationDelegate
- Tutorial
---

Expand All @@ -16,37 +17,45 @@ import Tabs from './tabs/javascript-from-native.md'

You can execute JavaScript in an in-app message from native code by completing the following steps:

* [Implement and assign a `MessagingDelegate`](#implement-and-assign-a-messagingdelegate)
* [Obtain a reference to the web view](#obtain-a-reference-to-the-web-view)
* [Implement and assign a `PresentationDelegate`/ `MessagingDelegate`](#implement-and-assign-a-presentationdelegate-messagingdelegate)
* [Obtain a reference to the web view](#obtain-a-reference-to-the-inappmessageeventhandler-web-view)
* [Call the JavaScript method](#call-the-javascript-method)

## Implement and assign a `MessagingDelegate`
## Implement and assign a `PresentationDelegate`/ `MessagingDelegate`

To register a JavaScript event handler with a `Message` object, you will first need to implement and set a `MessagingDelegate`.
To register a JavaScript event handler with a `Message` object, you will first need to implement and set a `PresentationDelegate` or `MessagingDelegate` (for older Android SDK versions and iOS SDK) you are using.

For more detailed instructions on implementing and using a MessagingDelegate, please read the [tutorial on using MessagingDelegate](./messaging-delegate.md).
Please read the [tutorial](./messaging-delegate.md) for more detailed instructions on implementing and using a PresentationDelegate/ MessagingDelegate (for older Android SDK versions and iOS SDK).

## Obtain a reference to the web view
## Obtain a reference to the `InAppMessageEventHandler`/ web view

In the `shouldShowMessage` function of the `MessagingDelegate`, get a reference to the web view used by the message.

<TabsBlock orientation="horizontal" slots="heading, content" repeat="2"/>
<TabsBlock orientation="horizontal" slots="heading, content" repeat="3"/>

Android
Android 3.x

<Tabs query="platform=android&task=obtain"/>
<Tabs query="platform=android3x&task=obtain"/>

Android 2.x (Older version)

<Tabs query="platform=android2x&task=obtain"/>

iOS

<Tabs query="platform=ios&task=obtain"/>

## Call the JavaScript method

<TabsBlock orientation="horizontal" slots="heading, content" repeat="2"/>
<TabsBlock orientation="horizontal" slots="heading, content" repeat="3"/>

Android 3.x

<Tabs query="platform=android3x&task=call"/>

Android
Android 2.x (Older version)

<Tabs query="platform=android&task=call"/>
<Tabs query="platform=android2x&task=call"/>

iOS

Expand All @@ -58,4 +67,4 @@ The test apps in this repository demonstrate executing JavaScript code from an i

* [Swift](https://github.com/adobe/aepsdk-messaging-ios/tree/main/TestApps/MessagingDemoApp)
* [Objective-C](https://github.com/adobe/aepsdk-messaging-ios/tree/main/TestApps/MessagingDemoAppObjC)
* [Java](https://github.com/adobe/aepsdk-messaging-android/tree/main/code/app)
* [Kotlin](https://github.com/adobe/aepsdk-messaging-android/tree/main/code/testapp)
Loading

0 comments on commit 236bb19

Please sign in to comment.