Add the required dependencies to your project by including them in the app's Gradle file.
Copied to your clipboardimplementation(platform("com.adobe.marketing.mobile:sdk-bom:3.+"))implementation("com.adobe.marketing.mobile:core")implementation("com.adobe.marketing.mobile:edgeidentity")implementation("com.adobe.marketing.mobile:edge")implementation("com.adobe.marketing.mobile:optimize")
Using dynamic dependency versions is not recommended for production apps. Please read the managing Gradle dependencies guide for more information.
Add the required dependencies to your project by including them in the app's Gradle file.
Copied to your clipboardimplementation platform('com.adobe.marketing.mobile:sdk-bom:3.+')implementation 'com.adobe.marketing.mobile:core'implementation 'com.adobe.marketing.mobile:edgeidentity'implementation 'com.adobe.marketing.mobile:edge'implementation 'com.adobe.marketing.mobile:optimize'
Using dynamic dependency versions is not recommended for production apps. Please read the managing Gradle dependencies guide for more information.
Add the required dependencies to your project using CocoaPods. Add following pods in your Podfile
:
Copied to your clipboarduse_frameworks!target 'YourAppTarget' dopod 'AEPCore', '~> 5.0'pod 'AEPEdge', '~> 5.0'pod 'AEPEdgeIdentity', '~> 5.0'pod 'AEPOptimize', '~> 5.0'end
Java
Copied to your clipboardfinal DecisionScope decisionScope = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 3);
Swift
Copied to your clipboardlet decisionScope = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111",itemCount: 3)
Objective-C
Copied to your clipboardAEPDecisionScope* decisionScope = [[AEPDecisionScope alloc] initWithActivityId:@"xcore:offer-activity:1111111111111111"placementId:@"xcore:offer-placement:1111111111111111"itemCount:3];
Java
Copied to your clipboardfinal DecisionScope decisionScope = DecisionScope("eyJ4ZG06YWN0aXZpdHlJZCI6Inhjb3JlOm9mZmVyLWFjdGl2aXR5OjEyYmEyZjM4MWJjYTY3NWUiLCJ4ZG06cGxhY2VtZW50SWQiOiJ4Y29yZTpvZmZlci1wbGFjZW1lbnQ6MTJiOWEwMDA1NTUwNzM1NyIsICJ4ZG06aXRlbUNvdW50IjozfQ==");
Swift
Copied to your clipboardlet decisionScope = DecisionScope(name: "eyJ4ZG06YWN0aXZpdHlJZCI6Inhjb3JlOm9mZmVyLWFjdGl2aXR5OjEyYmEyZjM4MWJjYTY3NWUiLCJ4ZG06cGxhY2VtZW50SWQiOiJ4Y29yZTpvZmZlci1wbGFjZW1lbnQ6MTJiOWEwMDA1NTUwNzM1NyIsICJ4ZG06aXRlbUNvdW50IjozfQ==")
Objective-C
Copied to your clipboardAEPDecisionScope* decisionScope = [[AEPDecisionScope alloc] initWithName:@"eyJ4ZG06YWN0aXZpdHlJZCI6Inhjb3JlOm9mZmVyLWFjdGl2aXR5OjEyYmEyZjM4MWJjYTY3NWUiLCJ4ZG06cGxhY2VtZW50SWQiOiJ4Y29yZTpvZmZlci1wbGFjZW1lbnQ6MTJiOWEwMDA1NTUwNzM1NyIsICJ4ZG06aXRlbUNvdW50IjozfQ=="];
Java
Copied to your clipboardfinal DecisionScope decisionScope = DecisionScope("myTargetLocation");
Swift
Copied to your clipboardlet decisionScope = DecisionScope(name: "myTargetLocation")
Objective-C
Copied to your clipboardAEPDecisionScope* decisionScope = [[AEPDecisionScope alloc] initWithName:@"myTargetLocation"];
Java
Copied to your clipboardfinal Map<String, Object> data = new HashMap<>();final Map<String, String> targetParameters = new HashMap<>();// Add mbox parameterstargetParameters.put("someKey", "someValue");// Add profile parameters - prefix with profile.targetParameters.put("profile.membershipLevel", "platinum");// Add product parameterstargetParameters.put("productId", "111");targetParameters.put("categoryId", "Books");// Add order parameterstargetParameters.put("orderId", "10");targetParameters.put("orderTotal", "110.56");targetParameters.put("purchasedProductIds", "111");data.put("__adobe", new HashMap<String, Object>() {{put("target", targetParameters);}});final DecisionScope decisionScope = DecisionScope("myTargetLocation") // Target location (or mbox)final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope);Optimize.updatePropositions(decisionScopes, null, data);
Swift
Copied to your clipboardvar data: [String: Any] = [:]var targetParameters: [String: String] = [:]// Add mbox parameterstargetParameters["someKey"] = "someValue"// Add profile parameters - prefix with profile.targetParameters["profile.membershipLevel"] = "platinum"// Add product parameterstargetParameters["productId"] = "111"targetParameters["categoryId"] = "Books"// Add order parameterstargetParameters["orderId"] = "10"targetParameters["orderTotal"] = "110.56"targetParameters["purchasedProductIds"] = "111"data["__adobe"] = ["target": targetParameters]let decisionScope = DecisionScope(name: "myTargetLocation") // Target location (or mbox)Optimize.updatePropositions(for: [decisionScope] withXdm: nil andData: data)
Objective-C
Copied to your clipboardNSMutableDictionary* data = [NSMutableDictionary dictionary];NSMutableDictionary* targetParameters = [NSMutableDictionary dictionary];// Add mbox parameterstargetParameters[@"someKey"] = @"someValue";// Add profile parameters - prefix with profile.targetParameters[@"profile.membershipLevel"] = @"platinum";// Add product parameterstargetParameters[@"productId"] = @"111";targetParameters[@"categoryId"] = @"Books";// Add order parameterstargetParameters[@"orderId"] = @"10";targetParameters[@"orderTotal"] = @"110.56";targetParameters[@"purchasedProductIds"] = @"111";[data setObject:[NSDictionary dictionaryWithObject:targetParameters forKey:@"target"] forKey:@"__adobe"];AEPDecisionScope* decisionScope = [[AEPDecisionScope alloc] initWithName:@"myTargetLocation"]; // Target location (or mbox)[AEPMobileOptimize updatePropositions:@[decisionScope] withXdm:nil andData:data];
Java
Copied to your clipboardfinal IdentityItem item = new IdentityItem("1111", AuthenticatedState.AUTHENTICATED, true);final IdentityMap identityMap = new IdentityMap();identityMap.addItem(item, "userCRMID") // userCRMID being used as Third Party IDIdentity.updateIdentities(identityMap);
Swift
Copied to your clipboardlet identityMap = IdentityMap()identityMap.add(item: IdentityItem(id: "1111", authenticatedState: AuthenticatedState.authenticated, primary: true),withNamespace: "userCRMID") // userCRMID being used as Third Party IDIdentity.updateIdentities(with: identityMap)
Objective-C
Copied to your clipboardAEPIdentityItem *item = [[AEPIdentityItem alloc] initWithId:@"1111" authenticatedState:AEPAuthenticatedStateAuthenticated primary:true];AEPIdentityMap *identityMap = [[AEPIdentityMap alloc] init];[identityMap addItem:item withNamespace:@"userCRMID"]; // userCRMID being used as Third Party ID[AEPMobileEdgeIdentity updateIdentities:identityMap];
Java
Copied to your clipboardpublic class Offer {.../*** 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.*/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.*/public void tapped() {...}}
Swift
Copied to your clipboardpublic extension Offer {/// Dispatches an event for the Edge extension to send an Experience Event to the Edge network with the display interaction data for the given proposition item.func displayed() {...}/// Dispatches an event for the Edge extension to send an Experience Event to the Edge network with the tap interaction data for the given proposition item.func tapped() {...}}
Copied to your clipboardoffer.displayed(); // Sends an Offer display notification to Edge network
Copied to your clipboardoffer.displayed() // Sends an Offer display notification to Edge network
Copied to your clipboardoffer.displayed() // Sends an Offer display notification to Edge network
Copied to your clipboard[offer displayed]; // Sends an Offer display notification to Edge network
Java
Copied to your clipboardpublic class Offer {.../*** Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code Proposition} item.** The returned XDM data does contain the {@code eventType} for the Experience Event with value {@code decisioning.propositionDisplay}.** Note: The Edge sendEvent API can be used to dispatch this data in an Experience Event along with any additional XDM, free-form data, and override* dataset identifier.** @return {@code Map<String, Object>} containing the XDM data for the proposition interaction.*/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.** The returned XDM data contains the {@code eventType} for the Experience Event with value {@code decisioning.propositionInteract}.** Note: The Edge sendEvent API can be used to dispatch this data in an Experience Event along with any additional XDM, free-form data, and override* dataset identifier.** @return {@code Map<String, Object>} containing the XDM data for the proposition interaction.*/public Map<String, Object> generateTapInteractionXdm() {...}}
Swift
Copied to your clipboardpublic extension Offer {/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Interactions` field group from the given proposition option.////// The Edge `sendEvent(experienceEvent:_:)` API can be used to dispatch this data in an Experience Event along with any additional XDM, free-form data, or override dataset identifier.////// - Note: The returned XDM data also contains the `eventType` for the Experience Event with value `decisioning.propositionDisplay`./// - Returns A dictionary containing XDM data for the proposition interactions.func generateDisplayInteractionXdm() -> [String: Any] {...}/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Interactions` field group from the given proposition option.////// The Edge `sendEvent(experienceEvent:_:)` API can be used to dispatch this data in an Experience Event along with any additional XDM, free-form data, or override dataset identifier.////// - Note: The returned XDM data also contains the `eventType` for the Experience Event with value `decisioning.propositionInteract`./// - Returns A dictionary containing XDM data for the proposition interactions.func generateTapInteractionXdm() -> [String: Any] {...}}
Copied to your clipboard// When a proposition is retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offer is displayed, invoke method on Offer object to get the XDM data.val displayInteractionXdm = offer.generateDisplayInteractionXdm() // Offer display tracking XDMval additionalData = mapOf("someDataKey" to "someDataValue")val experienceEvent = ExperienceEvent.Builder().setXdmSchema(displayInteractionXdm).setData(additionalData).build()Edge.sendEvent(experienceEvent, null)
Copied to your clipboard// When a proposition is retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offer is displayed, invoke method on Offer object to get the XDM data.final Map<String, Object> displayInteractionXdm = offer.generateDisplayInteractionXdm() // Offer display tracking XDMfinal Map<String, Object> additionalData = new HashMap<>();additionalData.put("someDataKey", "someDataValue");final ExperienceEvent experienceEvent = new ExperienceEvent.Builder().setXdmSchema(displayInteractionXdm).setData(additionalData).build();Edge.sendEvent(experienceEvent, null)
Copied to your clipboard// When a proposition is retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offer is displayed, invoke method on Offer object to get the XDM data.let displayInteractionXdm = offer.generateDisplayInteractionXdm() // Offer display tracking XDMlet additionalData: [String: Any] = ["someDataKey": "someDataValue"]let experienceEvent = ExperienceEvent(xdm: displayInteractionXdm, data: additionalData)Edge.sendEvent(experienceEvent)
Copied to your clipboard// When a proposition is retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offer is displayed, invoke method on Offer object to get the XDM data.NSDictionary* displayInteractionXdm = [offer generateDisplayInteractionXdm];NSDictionary* additionalData = @{@"someDataKey": @"someDataValue"};AEPExperienceEvent* experienceEvent = [[AEPExperienceEvent alloc] initWithXdm:displayInteractionXdm data:additionalData datasetIdentifier:nil];[AEPMobileEdge sendExperienceEvent:event completion:nil];
Copied to your clipboard// Create a list of offers from different propositionsfinal List<Offer> offersToDisplay = new ArrayList<>();offersToDisplay.add(proposition1.getOffers().get(0));offersToDisplay.add(proposition2.getOffers().get(0));// Send list of offers to multiple offers display track public APIOfferUtils.displayed(offersToDisplay);
Copied to your clipboard// Create a list of offers from different propositionsval offersToDisplay = listOf(proposition1.offers[0],proposition2.offers[0])// Send list of offers to multiple offers display track public APIoffersToDisplay.displayed()
Copied to your clipboard// Create an array of offers from different propositionslet offersToDisplay = [proposition1.offers[0],proposition2.offers[0]]// Send array of offers to multiple offers display track public APIOptimize.displayed(offersToDisplay)
Copied to your clipboard// Create an array of offers from different propositionsNSArray<AEPOffer *> *offersToDisplay = @[proposition1.offers[0],proposition2.offers[0]];// Send array of offers to multiple offers display track public API[AEPMobileOptimize displayed: offersToDisplay];
Copied to your clipboard// When propositions are retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offers are displayed, invoke method on List<Offer> to get the XDM data.final Map<String, Object> displayInteractionXdm = offers.generateDisplayInteractionXdm() // Offers display tracking XDMfinal Map<String, Object> additionalData = new HashMap<>();additionalData.put("someDataKey", "someDataValue");final ExperienceEvent experienceEvent = new ExperienceEvent.Builder().setXdmSchema(displayInteractionXdm).setData(additionalData).build();Edge.sendEvent(experienceEvent, null)
Parameters
- offers - A
List<Offer>
that may or may not belong to the same proposition. The associated proposition(s) need to be tracked.
Copied to your clipboard// When propositions are retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offers are displayed, invoke method on List<Offer> to get the XDM data.val displayInteractionXdm = offers.generateDisplayInteractionXdm() // Offers display tracking XDMval additionalData = mapOf("someDataKey" to "someDataValue")val experienceEvent = ExperienceEvent.Builder().setXdmSchema(displayInteractionXdm).setData(additionalData).build()Edge.sendEvent(experienceEvent, null)
Parameters
- offers - A
[Offer]
that may or may not belong to the same proposition. The associated proposition(s) need to be tracked.
Copied to your clipboard// When propositions are retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offers are displayed, invoke method on [Offer] to get the XDM data.let displayInteractionXdm = offers.generateDisplayInteractionXdm() // Offers display tracking XDMlet additionalData: [String: Any] = ["someDataKey": "someDataValue"]let experienceEvent = ExperienceEvent(xdm: displayInteractionXdm, data: additionalData)Edge.sendEvent(experienceEvent)
Parameters
- offers - A
[Offer]
that may or may not belong to the same proposition. The associated proposition(s) need to be tracked.
Copied to your clipboard// When propositions are retrieved using getPropositions API or onUpdatePropositions API callback// and the corresponding offers are displayed, invoke method on NSArray<AEPOffer *> to get the XDM data.NSDictionary* displayInteractionXdm = [offers generateDisplayInteractionXdm];NSDictionary* additionalData = @{@"someDataKey": @"someDataValue"};AEPExperienceEvent* experienceEvent = [[AEPExperienceEvent alloc] initWithXdm:displayInteractionXdm data:additionalData datasetIdentifier:nil];[AEPMobileEdge sendExperienceEvent:event completion:nil];
Parameters
- offers - A
List<Offer>
that may or may not belong to the same proposition. The associated proposition(s) need to be tracked.
Kotlin
Copied to your clipboardobject OfferUtils {/*** 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 list of [Offer]s.** This function extracts unique [OptimizeProposition]s from the list of offers based on their* proposition ID and dispatches an event with multiple propositions.** @see XDMUtils.trackWithData*/@JvmStaticfun List<Offer>.displayed() {...}}
Swift
Copied to your clipboard@objcpublic extension Optimize {/// This API dispatches an event for the Edge extension to send an Experience Event to the Edge network with the display interaction data for list of offers passed.////// - Parameter offers: An array of offer.@objc(displayed:)static func displayed(for offers: [Offer]) {...}}
Kotlin
Copied to your clipboardobject OfferUtils {/*** Generates a map containing XDM formatted data for `Experience Event - OptimizeProposition* Interactions` field group from the given list of [Offer]s.** This function extracts unique [OptimizeProposition]s from the list of offers based on their* proposition ID and generates XDM data for the interaction.** @return [Map] containing the XDM data for the proposition interaction, or null if the list is empty* or no valid propositions are found*/@JvmStaticfun List<Offer>.generateDisplayInteractionXdm(): Map<String, Any>? {...}}
Swift
Copied to your clipboard@objcpublic extension Optimize {/// This API returns a dictionary containing XDM formatted data for Experience Event - Proposition Interactions field group for the list of offers////// The Edge sendEvent(experienceEvent:_:) API can be used to dispatch this data in an Experience Event along with any additional XDM, free-form data, or override dataset identifier.////// - Parameter offers: An array of offer./// - Note: The returned XDM data also contains the eventType for the Experience Event with value decisioning.propositionInteract./// - Returns A dictionary containing XDM data for the propositon interactions./// - SeeAlso: interactionXdm(for:)@objc(generateDisplayInteractionXdm:)static func generateDisplayInteractionXdm(for offers: [Offer]) -> [String: Any]?{...}}
Copied to your clipboardimport com.google.gson.Gsonimport java.nio.charset.StandardCharsetsfun calculateJsonSizeInKB(jsonMap: Map<String, Any>) {val gson = Gson()val jsonString = gson.toJson(jsonMap)val byteArray = jsonString.toByteArray(StandardCharsets.UTF_8)val sizeInKB = byteArray.size / 1024.0println("JSON size: %.2f KB".format(sizeInKB))}
Copied to your clipboardimport Foundationfunc calculateJsonSizeInKB(jsonMap: [String: Any]) {do {let jsonData = try JSONSerialization.data(withJSONObject: jsonMap)let sizeInKB = Double(jsonData.count) / 1024.0print(String(format: "JSON size: %.2f KB", sizeInKB))} catch {print("Error calculating JSON size: \(error)")}}