API reference
clearPropositions
This API clears out the client-side in-memory propositions cache.
extensionVersion
The extensionVersion()
method (on Android) or the extensionVersion
property (on iOS) returns the version information for currently installed AEPOptimize extension.
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet extensionVersion = Optimize.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *extensionVersion = [AEPMobileOptimize extensionVersion];
Java
Syntax
Copied to your clipboardpublic static String extensionVersion()
Example
Copied to your clipboardOptimize.extensionVersion();
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet extensionVersion = Optimize.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *extensionVersion = [AEPMobileOptimize extensionVersion];
getPropositions
This API retrieves the previously fetched propositions, for the provided decision scopes, from the in-memory extension propositions cache. The completion callback is invoked with the decision propositions corresponding to the given decision scopes. If a certain decision scope has not already been fetched prior to this API call, it will not be contained in the returned propositions.
Java
Syntax
Copied to your clipboardpublic 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 typeMap<DecisionScope, OptimizeProposition>
. If the callback is an instance of AdobeCallbackWithError, and if the operation times out or an error occurs in retrieving propositions, thefail
method is invoked with the appropriate AdobeError.
Example
Copied to your clipboardfinal DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);final DecisionScope decisionScope2 = new DecisionScope("myScope");final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope1);decisionScopes.add(decisionScope2);Optimize.getPropositions(scopes, new AdobeCallbackWithError<Map<DecisionScope, OptimizeProposition>>() {@Overridepublic void fail(final AdobeError adobeError) {// handle error}@Overridepublic void call(Map<DecisionScope, OptimizeProposition> propositionsMap) {if (propositionsMap != null && !propositionsMap.isEmpty()) {// get the propositions for the given decision scopesif (propositionsMap.contains(decisionScope1)) {final OptimizeProposition proposition1 = propsMap.get(decisionScope1)// read proposition1 offers}if (propositionsMap.contains(decisionScope2)) {final OptimizeProposition proposition2 = propsMap.get(decisionScope2)// read proposition2 offers}}}});
Swift
Syntax
Copied to your clipboardstatic func getPropositions(for decisionScopes: [DecisionScope],_ completion: @escaping ([DecisionScope: OptimizeProposition]?, Error?) -> Void)
- decisionScopes is an array of decision scopes for which propositions are requested.
- completion is invoked with propositions dictionary of type
[DecisionScope: OptimizeProposition]
. AnError
is returned if SDK fails to retrieve the propositions.
Example
Copied to your clipboardlet decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111"itemCount: 2)let decisionScope2 = DecisionScope(name: "myScope")Optimize.getPropositions(for: [decisionScope1, decisionScope2]) { propositionsDict, error inif let error = error {// handle errorreturn}if let propositionsDict = propositionsDict {// get the propositions for the given decision scopesif let proposition1 = propositionsDict[decisionScope1] {// read proposition1 offers}if let proposition2 = propositionsDict[decisionScope2] {// read proposition2 offers}}}
Objective-C
Syntax
Copied to your clipboard+ (void) getPropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopescompletion: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* _Nullable propositionsDict, NSError* _Nullable error)) completion;
- decisionScopes is an array of decision scopes for which propositions are requested.
- completion is invoked with propositions dictionary of type
NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>
. AnNSError
is returned if SDK fails to retrieve the propositions.
Example
Copied to your clipboardAEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"placementId: @"xcore:offer-placement:1111111111111111"itemCount: 2];AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];[AEPMobileOptimize getPropositions: @[decisionScope1, decisionScope2]completion: ^(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* propositionsDict, NSError* error) {if (error != nil) {// handle errorreturn;}AEPOptimizeProposition* proposition1 = propositionsDict[decisionScope1];// read proposition1 offersAEPOptimizeProposition* proposition2 = propositionsDict[decisionScope2];// read proposition2 offers}];
Java
Syntax
Copied to your clipboardpublic 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 typeMap<DecisionScope, OptimizeProposition>
. If the callback is an instance of AdobeCallbackWithError, and if the operation times out or an error occurs in retrieving propositions, thefail
method is invoked with the appropriate AdobeError.
Example
Copied to your clipboardfinal DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);final DecisionScope decisionScope2 = new DecisionScope("myScope");final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope1);decisionScopes.add(decisionScope2);Optimize.getPropositions(scopes, new AdobeCallbackWithError<Map<DecisionScope, OptimizeProposition>>() {@Overridepublic void fail(final AdobeError adobeError) {// handle error}@Overridepublic void call(Map<DecisionScope, OptimizeProposition> propositionsMap) {if (propositionsMap != null && !propositionsMap.isEmpty()) {// get the propositions for the given decision scopesif (propositionsMap.contains(decisionScope1)) {final OptimizeProposition proposition1 = propsMap.get(decisionScope1)// read proposition1 offers}if (propositionsMap.contains(decisionScope2)) {final OptimizeProposition proposition2 = propsMap.get(decisionScope2)// read proposition2 offers}}}});
Swift
Syntax
Copied to your clipboardstatic func getPropositions(for decisionScopes: [DecisionScope],_ completion: @escaping ([DecisionScope: OptimizeProposition]?, Error?) -> Void)
- decisionScopes is an array of decision scopes for which propositions are requested.
- completion is invoked with propositions dictionary of type
[DecisionScope: OptimizeProposition]
. AnError
is returned if SDK fails to retrieve the propositions.
Example
Copied to your clipboardlet decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111"itemCount: 2)let decisionScope2 = DecisionScope(name: "myScope")Optimize.getPropositions(for: [decisionScope1, decisionScope2]) { propositionsDict, error inif let error = error {// handle errorreturn}if let propositionsDict = propositionsDict {// get the propositions for the given decision scopesif let proposition1 = propositionsDict[decisionScope1] {// read proposition1 offers}if let proposition2 = propositionsDict[decisionScope2] {// read proposition2 offers}}}
Objective-C
Syntax
Copied to your clipboard+ (void) getPropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopescompletion: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* _Nullable propositionsDict, NSError* _Nullable error)) completion;
- decisionScopes is an array of decision scopes for which propositions are requested.
- completion is invoked with propositions dictionary of type
NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>
. AnNSError
is returned if SDK fails to retrieve the propositions.
Example
Copied to your clipboardAEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"placementId: @"xcore:offer-placement:1111111111111111"itemCount: 2];AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];[AEPMobileOptimize getPropositions: @[decisionScope1, decisionScope2]completion: ^(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* propositionsDict, NSError* error) {if (error != nil) {// handle errorreturn;}AEPOptimizeProposition* proposition1 = propositionsDict[decisionScope1];// read proposition1 offersAEPOptimizeProposition* proposition2 = propositionsDict[decisionScope2];// read proposition2 offers}];
onPropositionsUpdate
This API registers a permanent callback which is invoked whenever the Edge extension dispatches a response event with an eventType
of personalization.response
. Additionally, the callback is only invoked if the response event contains at least one valid offer. The personalization response can be triggered by the updatePropositions
API.
The callback passed to onPropositionsUpdate
will not be invoked if the Experience Edge Network returns an error for the personalization query, or if the response event payload is empty or has invalid proposition data. This API should not be used for handling errors that might occur when updatePropositions
is called.
Java
Syntax
Copied to your clipboardpublic static void onPropositionsUpdate(final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
- callback
call
method is invoked with propositions map of typeMap<DecisionScope, OptimizeProposition>
. Errors and empty responses for personalization queries are not passed back in thecall
method.
Example
Copied to your clipboardOptimize.onPropositionsUpdate(new AdobeCallback<Map<DecisionScope, OptimizeProposition>>() {@Overridepublic void call(final Map<DecisionScope, OptimizeProposition> propositionsMap) {if (propositionsMap != null && !propositionsMap.isEmpty()) {// handle propositions}}});
Swift
Syntax
Copied to your clipboardstatic func onPropositionsUpdate(perform action: @escaping ([DecisionScope: OptimizeProposition]?) -> Void)
- action is invoked with propositions dictionary of type
[DecisionScope: OptimizeProposition]
. Errors and empty responses for personalization queries are not passed back in action.
Example
Copied to your clipboardOptimize.onPropositionsUpdate { propositionsDict inif let propositionsDict = propositionsDict {// handle propositions}}
Objective-C
Syntax
Copied to your clipboard+ (void) onPropositionsUpdate: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* _Nullable)) action;
- action is invoked with propositions dictionary of type
NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>
. Errors and empty responses for personalization queries are not passed back in action.
Example
Copied to your clipboard[AEPMobileOptimize onPropositionsUpdate: ^(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* propositionsDict) {// handle propositions}];
Java
Syntax
Copied to your clipboardpublic static void onPropositionsUpdate(final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
- callback
call
method is invoked with propositions map of typeMap<DecisionScope, OptimizeProposition>
. Errors and empty responses for personalization queries are not passed back in thecall
method.
Example
Copied to your clipboardOptimize.onPropositionsUpdate(new AdobeCallback<Map<DecisionScope, OptimizeProposition>>() {@Overridepublic void call(final Map<DecisionScope, OptimizeProposition> propositionsMap) {if (propositionsMap != null && !propositionsMap.isEmpty()) {// handle propositions}}});
Swift
Syntax
Copied to your clipboardstatic func onPropositionsUpdate(perform action: @escaping ([DecisionScope: OptimizeProposition]?) -> Void)
- action is invoked with propositions dictionary of type
[DecisionScope: OptimizeProposition]
. Errors and empty responses for personalization queries are not passed back in action.
Example
Copied to your clipboardOptimize.onPropositionsUpdate { propositionsDict inif let propositionsDict = propositionsDict {// handle propositions}}
Objective-C
Syntax
Copied to your clipboard+ (void) onPropositionsUpdate: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* _Nullable)) action;
- action is invoked with propositions dictionary of type
NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>
. Errors and empty responses for personalization queries are not passed back in action.
Example
Copied to your clipboard[AEPMobileOptimize onPropositionsUpdate: ^(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* propositionsDict) {// handle propositions}];
registerExtension
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use MobileCore.registerExtensions()
API instead.
resetIdentities
This API call can lead to unintended SDK behavior, e.g. resetting of Experience Cloud ID (ECID). So it should be sparingly used and caution should be followed!
This MobileCore
API is a request to each extension to reset its identities. Every extension responds to this request in its own unique manner. For example, Optimize extension uses this API call to clear out its client-side in-memory propositions cache.
For details on syntax, usage and availability, refer to Mobile Core - Reset identities.
updatePropositions
This API dispatches an Event for the Edge network extension to fetch decision propositions, for the provided decision scopes array, from the decisioning services enabled in the Experience Edge. The returned decision propositions are cached in-memory in the Optimize SDK extension and can be retrieved using getPropositions
API.
Java
Syntax
Copied to your clipboardpublic static void updatePropositions(final List<DecisionScope> decisionScopes, final Map<String, Object> xdm, final Map<String, Object> data)
- decisionScopes is a list of decision scopes for which propositions need updating.
- xdm is a map containing additional xdm formatted data to be attached to the Experience Event.
- data is a map containing additional freeform data to be attached to the Experience Event.
Example
Copied to your clipboardfinal DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);final DecisionScope decisionScope2 = new DecisionScope("myScope");final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope1);decisionScopes.add(decisionScope2);Optimize.updatePropositions(decisionScopes,new HashMap<String, Object>() {{put("xdmKey", "xdmValue");}},new HashMap<String, Object>() {{put("dataKey", "dataValue");}});
Swift
Syntax
Copied to your clipboardstatic func updatePropositions(for decisionScopes: [DecisionScope],withXdm xdm: [String: Any]?,andData data: [String: Any]? = nil)
- decisionScopes is an array of decision scopes for which propositions need updating.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
Example
Copied to your clipboardlet decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111"itemCount: 2)let decisionScope2 = DecisionScope(name: "myScope")Optimize.updatePropositions(for: [decisionScope1, decisionScope2]withXdm: ["xdmKey": "xdmValue"]andData: ["dataKey": "dataValue"])
Objective-C
Syntax
Copied to your clipboard+ (void) updatePropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopeswithXdm: (NSDictionary<NSString*, id>* _Nullable) xdmandData: (NSDictionary<NSString*, id>* _Nullable) data;
- decisionScopes is an array of decision scopes for which propositions need updating.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
Example
Copied to your clipboardAEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"placementId: @"xcore:offer-placement:1111111111111111"itemCount: 2];AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];[AEPMobileOptimize updatePropositions: @[decisionScope1, decisionScope2]withXdm: @{@"xdmKey": @"xdmValue"}andData: @{@"dataKey": @"dataValue"}];
Java
Syntax
Copied to your clipboardpublic static void updatePropositions(final List<DecisionScope> decisionScopes, final Map<String, Object> xdm, final Map<String, Object> data)
- decisionScopes is a list of decision scopes for which propositions need updating.
- xdm is a map containing additional xdm formatted data to be attached to the Experience Event.
- data is a map containing additional freeform data to be attached to the Experience Event.
Example
Copied to your clipboardfinal DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);final DecisionScope decisionScope2 = new DecisionScope("myScope");final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope1);decisionScopes.add(decisionScope2);Optimize.updatePropositions(decisionScopes,new HashMap<String, Object>() {{put("xdmKey", "xdmValue");}},new HashMap<String, Object>() {{put("dataKey", "dataValue");}});
Swift
Syntax
Copied to your clipboardstatic func updatePropositions(for decisionScopes: [DecisionScope],withXdm xdm: [String: Any]?,andData data: [String: Any]? = nil)
- decisionScopes is an array of decision scopes for which propositions need updating.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
Example
Copied to your clipboardlet decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111"itemCount: 2)let decisionScope2 = DecisionScope(name: "myScope")Optimize.updatePropositions(for: [decisionScope1, decisionScope2]withXdm: ["xdmKey": "xdmValue"]andData: ["dataKey": "dataValue"])
Objective-C
Syntax
Copied to your clipboard+ (void) updatePropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopeswithXdm: (NSDictionary<NSString*, id>* _Nullable) xdmandData: (NSDictionary<NSString*, id>* _Nullable) data;
- decisionScopes is an array of decision scopes for which propositions need updating.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
Example
Copied to your clipboardAEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"placementId: @"xcore:offer-placement:1111111111111111"itemCount: 2];AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];[AEPMobileOptimize updatePropositions: @[decisionScope1, decisionScope2]withXdm: @{@"xdmKey": @"xdmValue"}andData: @{@"dataKey": @"dataValue"}];
updatePropositionsWithCompletionHandler
This API dispatches an event for the Edge network extension to fetch decision propositions, for the provided decision scopes array, from the decisioning services enabled in the Experience Edge. The returned decision propositions are cached in-memory in the Optimize SDK extension and can be retrieved using getPropositions
API.
Completion callback passed to updatePropositions
supports network timeout and fatal errors returned by edge network along with fetched propositions data. The SDK's internal retry mechanism handles the recoverable HTTP errors. As a result, recoverable HTTP errors are not returned through this callback.
Java
Syntax
Copied to your clipboardpublic static void updatePropositions(final List<DecisionScope> decisionScopes,final Map<String, Object> xdm,final Map<String, Object> data,final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
- decisionScopes is a list of decision scopes for which propositions need updating.
- xdm is a map containing additional xdm formatted data to be attached to the Experience Event.
- data is a map containing additional freeform data to be attached to the Experience Event.
- callback is an optional completion handler that is invoked at the completion of the edge request.
call
method is invoked with propositions map of typeMap<DecisionScope, OptimizeProposition>
. If the callback is an instance ofAdobeCallbackWithOptimizeError
, and if the operation times out or an error occurs in retrieving propositions, thefail
method is invoked with the appropriate AEPOptimizeError. Note: In certain cases, both the success and failure callbacks may be triggered. To handle these cases, ensure that your implementation checks for both successful propositions and errors within the callback, as both may be present simultaneously.
Example
Copied to your clipboardfinal DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);final DecisionScope decisionScope2 = new DecisionScope("myScope");final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope1);decisionScopes.add(decisionScope2);Optimize.updatePropositions(decisionScopes,new HashMap<String, Object>() {{put("xdmKey", "xdmValue");}},new HashMap<String, Object>() {{put("dataKey", "dataValue");}},new AdobeCallbackWithOptimizeError<Map<DecisionScope, OptimizeProposition>>() {@Overridepublic void fail(AEPOptimizeError optimizeError) {responseError = optimizeError;}@Overridepublic void call(Map<DecisionScope, OptimizeProposition> propositionsMap) {responseMap = propositionsMap;}});
Swift
Syntax
Copied to your clipboardstatic func updatePropositions(for decisionScopes: [DecisionScope],withXdm xdm: [String: Any]?,andData data: [String: Any]? = nil,_completion: (([DecisionScope: OptimizeProposition]?, Error?) -> Void)? = nil)
- decisionScopes is an array of decision scopes for which propositions need updating.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
- completion is a optional completion handler invoked at the completion of the edge request with map of successful decision scopes to propositions and errors, if any.
Example
Copied to your clipboardlet decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111"itemCount: 2)let decisionScope2 = DecisionScope(name: "myScope")Optimize.updatePropositions(for: [decisionScope1, decisionScope2]withXdm: ["xdmKey": "xdmValue"]andData: ["dataKey": "dataValue"]) { data, error inif let error = error as? AEPOptimizeError {// handle error}}
Objective-C
Syntax
Copied to your clipboard+ (void) updatePropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopeswithXdm: (NSDictionary<NSString*, id>* _Nullable) xdmandData: (NSDictionary<NSString*, id>* _Nullable) datacompletion: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* _Nullable propositionsDict, NSError* _Nullable error)) completion;
- decisionScopes is an array of decision scopes for which propositions are requested.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
- completion is invoked with propositions dictionary of type
NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>
. AnNSError
is returned if SDK fails to retrieve the propositions.
Example
Copied to your clipboardAEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"placementId: @"xcore:offer-placement:1111111111111111"itemCount: 2];AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];[AEPMobileOptimize updatePropositions: @[decisionScope1, decisionScope2]withXdm: @{@"xdmKey": @"xdmValue"}andData: @{@"dataKey": @"dataValue"}]completion: ^(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* propositionsDict, NSError* error) {if (error != nil) {// handle errorreturn;}AEPOptimizeProposition* proposition1 = propositionsDict[decisionScope1];// read proposition1 offersAEPOptimizeProposition* proposition2 = propositionsDict[decisionScope2];// read proposition2 offers}];
Java
Syntax
Copied to your clipboardpublic static void updatePropositions(final List<DecisionScope> decisionScopes,final Map<String, Object> xdm,final Map<String, Object> data,final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
- decisionScopes is a list of decision scopes for which propositions need updating.
- xdm is a map containing additional xdm formatted data to be attached to the Experience Event.
- data is a map containing additional freeform data to be attached to the Experience Event.
- callback is an optional completion handler that is invoked at the completion of the edge request.
call
method is invoked with propositions map of typeMap<DecisionScope, OptimizeProposition>
. If the callback is an instance ofAdobeCallbackWithOptimizeError
, and if the operation times out or an error occurs in retrieving propositions, thefail
method is invoked with the appropriate AEPOptimizeError. Note: In certain cases, both the success and failure callbacks may be triggered. To handle these cases, ensure that your implementation checks for both successful propositions and errors within the callback, as both may be present simultaneously.
Example
Copied to your clipboardfinal DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);final DecisionScope decisionScope2 = new DecisionScope("myScope");final List<DecisionScope> decisionScopes = new ArrayList<>();decisionScopes.add(decisionScope1);decisionScopes.add(decisionScope2);Optimize.updatePropositions(decisionScopes,new HashMap<String, Object>() {{put("xdmKey", "xdmValue");}},new HashMap<String, Object>() {{put("dataKey", "dataValue");}},new AdobeCallbackWithOptimizeError<Map<DecisionScope, OptimizeProposition>>() {@Overridepublic void fail(AEPOptimizeError optimizeError) {responseError = optimizeError;}@Overridepublic void call(Map<DecisionScope, OptimizeProposition> propositionsMap) {responseMap = propositionsMap;}});
Swift
Syntax
Copied to your clipboardstatic func updatePropositions(for decisionScopes: [DecisionScope],withXdm xdm: [String: Any]?,andData data: [String: Any]? = nil,_completion: (([DecisionScope: OptimizeProposition]?, Error?) -> Void)? = nil)
- decisionScopes is an array of decision scopes for which propositions need updating.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
- completion is a optional completion handler invoked at the completion of the edge request with map of successful decision scopes to propositions and errors, if any.
Example
Copied to your clipboardlet decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",placementId: "xcore:offer-placement:1111111111111111"itemCount: 2)let decisionScope2 = DecisionScope(name: "myScope")Optimize.updatePropositions(for: [decisionScope1, decisionScope2]withXdm: ["xdmKey": "xdmValue"]andData: ["dataKey": "dataValue"]) { data, error inif let error = error as? AEPOptimizeError {// handle error}}
Objective-C
Syntax
Copied to your clipboard+ (void) updatePropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopeswithXdm: (NSDictionary<NSString*, id>* _Nullable) xdmandData: (NSDictionary<NSString*, id>* _Nullable) datacompletion: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* _Nullable propositionsDict, NSError* _Nullable error)) completion;
- decisionScopes is an array of decision scopes for which propositions are requested.
- xdm is a dictionary containing additional xdm formatted data to be attached to the Experience Event.
- data is a dictionary containing additional freeform data to be attached to the Experience Event.
- completion is invoked with propositions dictionary of type
NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>
. AnNSError
is returned if SDK fails to retrieve the propositions.
Example
Copied to your clipboardAEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"placementId: @"xcore:offer-placement:1111111111111111"itemCount: 2];AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];[AEPMobileOptimize updatePropositions: @[decisionScope1, decisionScope2]withXdm: @{@"xdmKey": @"xdmValue"}andData: @{@"dataKey": @"dataValue"}]completion: ^(NSDictionary<AEPDecisionScope*, AEPOptimizeProposition*>* propositionsDict, NSError* error) {if (error != nil) {// handle errorreturn;}AEPOptimizeProposition* proposition1 = propositionsDict[decisionScope1];// read proposition1 offersAEPOptimizeProposition* proposition2 = propositionsDict[decisionScope2];// read proposition2 offers}];
Public classes
Type | Android | (AEP 5.x) Swift | (AEP 5.x) Objective-C |
---|---|---|---|
class | DecisionScope | DecisionScope | AEPDecisionScope |
class | Proposition | OptimizeProposition | AEPOptimizeProposition |
class | Offer | Offer | AEPOffer |
class | AEPOptimizeError | AEPOptimizeError | AEPOptimizeError |
DecisionScope
This class represents the decision scope which is used to fetch the decision propositions from the Edge decisioning services. The encapsulated scope name can also represent the Base64-encoded JSON string created using the provided activityId, placementId, and itemCount.
Java
Copied to your clipboard/*** {@code DecisionScope} class represents a scope used to fetch personalized offers from the Experience Edge network.*/public class DecisionScope {/*** Constructor creates a {@code DecisionScope} using the provided {@code name}.** @param name {@link String} containing scope name.*/public DecisionScope(final String name) {...}/*** Constructor creates a {@code DecisionScope} using the provided {@code activityId} and {@code placementId}.** This constructor assumes the item count for the given scope to be {@value #DEFAULT_ITEM_COUNT}.** @param activityId {@link String} containing activity identifier for the given scope.* @param placementId {@code String} containing placement identifier for the given scope.*/public DecisionScope(final String activityId, final String placementId) {...}/*** Constructor creates a {@code DecisionScope} using the provided {@code activityId} and {@code placementId}.** @param activityId {@link String} containing activity identifier for the given scope.* @param placementId {@code String} containing placement identifier for the given scope.* @param itemCount {@code String} containing number of items to be returned for the given scope.*/public DecisionScope(final String activityId, final String placementId, final int itemCount) {...}/*** Gets the name for this scope.** @return {@link String} containing the scope name.*/public String getName() {...}}
Swift
Copied to your clipboard/// `DecisionScope` class is used to create decision scopes for personalization query requests to Experience Edge Network.@objc(AEPDecisionScope)public class DecisionScope: NSObject, Codable {/// Decision scope name@objc public let name: String/// Creates a new decision scope using the given scope `name`.////// - Parameter name: string representation for the decision scope.@objcpublic init(name: String) {...}/// Creates a new decision scope using the given `activityId`, `placementId` and `itemCount`.////// This initializer creates a scope name by Base64 encoding the JSON string created using the provided data.////// If `itemCount` == 1, JSON string is////// {"activityId":#activityId,"placementId":#placementId}/// otherwise,////// {"activityId":#activityId,"placementId":#placementId,"itemCount":#itemCount}/// - Parameters:/// - activityId: unique activity identifier for the decisioning activity./// - placementId: unique placement identifier for the decisioning activity offer./// - itemCount: number of offers to be returned from the server.@objcpublic convenience init(activityId: String, placementId: String, itemCount: UInt = 1) {...}}
Java
Copied to your clipboard/*** {@code DecisionScope} class represents a scope used to fetch personalized offers from the Experience Edge network.*/public class DecisionScope {/*** Constructor creates a {@code DecisionScope} using the provided {@code name}.** @param name {@link String} containing scope name.*/public DecisionScope(final String name) {...}/*** Constructor creates a {@code DecisionScope} using the provided {@code activityId} and {@code placementId}.** This constructor assumes the item count for the given scope to be {@value #DEFAULT_ITEM_COUNT}.** @param activityId {@link String} containing activity identifier for the given scope.* @param placementId {@code String} containing placement identifier for the given scope.*/public DecisionScope(final String activityId, final String placementId) {...}/*** Constructor creates a {@code DecisionScope} using the provided {@code activityId} and {@code placementId}.** @param activityId {@link String} containing activity identifier for the given scope.* @param placementId {@code String} containing placement identifier for the given scope.* @param itemCount {@code String} containing number of items to be returned for the given scope.*/public DecisionScope(final String activityId, final String placementId, final int itemCount) {...}/*** Gets the name for this scope.** @return {@link String} containing the scope name.*/public String getName() {...}}
Swift
Copied to your clipboard/// `DecisionScope` class is used to create decision scopes for personalization query requests to Experience Edge Network.@objc(AEPDecisionScope)public class DecisionScope: NSObject, Codable {/// Decision scope name@objc public let name: String/// Creates a new decision scope using the given scope `name`.////// - Parameter name: string representation for the decision scope.@objcpublic init(name: String) {...}/// Creates a new decision scope using the given `activityId`, `placementId` and `itemCount`.////// This initializer creates a scope name by Base64 encoding the JSON string created using the provided data.////// If `itemCount` == 1, JSON string is////// {"activityId":#activityId,"placementId":#placementId}/// otherwise,////// {"activityId":#activityId,"placementId":#placementId,"itemCount":#itemCount}/// - Parameters:/// - activityId: unique activity identifier for the decisioning activity./// - placementId: unique placement identifier for the decisioning activity offer./// - itemCount: number of offers to be returned from the server.@objcpublic convenience init(activityId: String, placementId: String, itemCount: UInt = 1) {...}}
OptimizeProposition
This class represents the decision propositions received from the decisioning services, upon a personalization query request to the Experience Edge network.
In SDK versions lower than Android 3.0.0 and iOS 5.0.0, this class was named Proposition
Java
Copied to your clipboardpublic class OptimizeProposition {/*** 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.*/OptimizeProposition(final String id, final List<Offer> offers, final String scope, final Map<String, Object> scopeDetails) {...}/*** Gets the {@code OptimizeProposition} identifier.** @return {@link String} containing the {@link OptimizeProposition} identifier.*/public String getId() {...}/*** Gets the {@code OptimizeProposition} items.** @return {@code List<Offer>} containing the {@link OptimizeProposition} items.*/public List<Offer> getOffers() {...}/*** Gets the {@code OptimizeProposition} scope.** @return {@link String} containing the encoded {@link OptimizeProposition} scope.*/public String getScope() {...}/*** Gets the {@code OptimizeProposition} 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 - 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 OptimizeProposition reference.*/public Map<String, Object> generateReferenceXdm() {...}}
Swift
Copied to your clipboard/// `OptimizeProposition` class@objc(AEPOptimizeProposition)public class OptimizeProposition: NSObject, Codable {/// Unique proposition identifier@objc public let id: String/// Array containing proposition decision options@objc public lazy var offers: [Offer] = {...}()/// Decision scope string@objc public let scope: String/// Scope details dictionary@objc public var scopeDetails: [String: Any]}
The OptimizeProposition
class extension provides a method for generating XDM data for Proposition Reference field group which can be used for proposition tracking.
Copied to your clipboard/// `OptimizeProposition` extension@objcpublic extension OptimizeProposition {/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Reference` field group from the given proposition.////// 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 does not contain an `eventType` for the Experience Event./// - Returns A dictionary containing XDM data for the proposition reference.func generateReferenceXdm() -> [String: Any] {...}}
Java
Copied to your clipboardpublic class OptimizeProposition {/*** 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.*/OptimizeProposition(final String id, final List<Offer> offers, final String scope, final Map<String, Object> scopeDetails) {...}/*** Gets the {@code OptimizeProposition} identifier.** @return {@link String} containing the {@link OptimizeProposition} identifier.*/public String getId() {...}/*** Gets the {@code OptimizeProposition} items.** @return {@code List<Offer>} containing the {@link OptimizeProposition} items.*/public List<Offer> getOffers() {...}/*** Gets the {@code OptimizeProposition} scope.** @return {@link String} containing the encoded {@link OptimizeProposition} scope.*/public String getScope() {...}/*** Gets the {@code OptimizeProposition} 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 - 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 OptimizeProposition reference.*/public Map<String, Object> generateReferenceXdm() {...}}
Swift
Copied to your clipboard/// `OptimizeProposition` class@objc(AEPOptimizeProposition)public class OptimizeProposition: NSObject, Codable {/// Unique proposition identifier@objc public let id: String/// Array containing proposition decision options@objc public lazy var offers: [Offer] = {...}()/// Decision scope string@objc public let scope: String/// Scope details dictionary@objc public var scopeDetails: [String: Any]}
The OptimizeProposition
class extension provides a method for generating XDM data for Proposition Reference field group which can be used for proposition tracking.
Copied to your clipboard/// `OptimizeProposition` extension@objcpublic extension OptimizeProposition {/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Reference` field group from the given proposition.////// 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 does not contain an `eventType` for the Experience Event./// - Returns A dictionary containing XDM data for the proposition reference.func generateReferenceXdm() -> [String: Any] {...}}
Offer
This class represents the proposition option received from the decisioning services, upon a personalization query to the Experience Edge network.
Java
Copied to your clipboardpublic class Offer {/*** {@code Offer} Builder.*/public static class Builder {/*** Builder constructor with required {@code Offer} attributes as parameters.** It sets default values for remaining {@link Offer} attributes.** @param id required {@link String} containing {@code Offer} identifier.* @param type required {@link OfferType} indicating the {@code Offer} type.* @param content required {@code String} containing the {@code Offer} content.*/public Builder(final String id, final OfferType type, final String content) {...}/*** Sets the etag for this {@code Offer}.** @param etag {@link String} containing {@link Offer} etag.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setEtag(final String etag) {...}/*** Sets the score for this {@code Offer}.** @param score {@code int} containing {@link Offer} score.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setScore(final int score) {...}/*** Sets the schema for this {@code Offer}.** @param schema {@link String} containing {@link Offer} schema.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setSchema(final String schema) {...}/*** Sets the metadata for this {@code Offer}.** @param meta {@code Map<String, Object>} containing {@link Offer} metadata.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setMeta(final Map<String, Object> meta) {...}/*** Sets the language for this {@code Offer}.** @param language {@code List<String>} containing supported {@link Offer} language.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setLanguage(final List<String> language) {...}/*** Sets the characteristics for this {@code Offer}.** @param characteristics {@code Map<String, String>} containing {@link Offer} characteristics.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setCharacteristics(final Map<String, String> characteristics) {...}/*** Builds and returns the {@code Offer} object.** @return {@link Offer} object or null.* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Offer build() {...}}/*** Gets the {@code Offer} identifier.** @return {@link String} containing the {@link Offer} identifier.*/public String getId() {...}/*** Gets the {@code Offer} etag.** @return {@link String} containing the {@link Offer} etag.*/public String getEtag() {...}/*** Gets the {@code Offer} score.** @return {@code int} containing the {@link Offer} score.*/public int getScore() {...}/*** Gets the {@code Offer} schema.** @return {@link String} containing the {@link Offer} schema.*/public String getSchema() {...}/*** Gets the {@code Offer} metadata.** @return {@code Map<String, Object>} containing the {@link Offer} metadata.*/public Map<String, Object> getMeta() {...}/*** Gets the {@code Offer} type.** @return {@link OfferType} indicating the {@link Offer} type.*/public OfferType getType() {...}/*** Gets the {@code Offer} language.** @return {@code List<String>} containing the supported {@link Offer} language.*/public List<String> getLanguage() {...}/*** Gets the {@code Offer} content.** @return {@link String} containing the {@link Offer} content.*/public String getContent() {...}/*** Gets the {@code Offer} characteristics.** @return {@code Map<String, String>} containing the {@link Offer} characteristics.*/public Map<String, String> getCharacteristics() {...}/*** Gets the containing {@code OptimizeProposition} for this {@code Offer}.** @return {@link OptimizeProposition} instance.*/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 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 OptimizeProposition} offer.*/public void tapped() {...}/*** 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}.** 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 OptimizeProposition} 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 clipboard/// `Offer` class@objc(AEPOffer)public class Offer: NSObject, Codable {/// Unique Offer identifier@objc public let id: String/// Offer revision detail at the time of the request@objc public let etag: String/// Offer priority score@objc public let score: Double/// Offer schema string@objc public let schema: String/// Offer metadata@objc public let meta: [String: Any]?/// Offer type as represented in enum `OfferType`@objc public let type: OfferType/// Optional Offer language array@objc public let language: [String]?/// Offer content string@objc public let content: String/// Optional Offer characteristics dictionary@objc public let characteristics: [String: String]?}
The Offer
class extension provides methods for generating XDM data for Proposition Interactions field group which can be used for proposition tracking. It also contains direct methods for tracking proposition display and tap interactions.
Copied to your clipboard/// `Offer` extension@objcpublic 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./// If the proposition reference within the option is released and no longer valid, the method returns `nil`.////// - 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./// If the proposition reference within the option is released and no longer valid, the method returns `nil`.////// - 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]? {...}/// 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() {...}}
Java
Copied to your clipboardpublic class Offer {/*** {@code Offer} Builder.*/public static class Builder {/*** Builder constructor with required {@code Offer} attributes as parameters.** It sets default values for remaining {@link Offer} attributes.** @param id required {@link String} containing {@code Offer} identifier.* @param type required {@link OfferType} indicating the {@code Offer} type.* @param content required {@code String} containing the {@code Offer} content.*/public Builder(final String id, final OfferType type, final String content) {...}/*** Sets the etag for this {@code Offer}.** @param etag {@link String} containing {@link Offer} etag.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setEtag(final String etag) {...}/*** Sets the score for this {@code Offer}.** @param score {@code int} containing {@link Offer} score.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setScore(final int score) {...}/*** Sets the schema for this {@code Offer}.** @param schema {@link String} containing {@link Offer} schema.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setSchema(final String schema) {...}/*** Sets the metadata for this {@code Offer}.** @param meta {@code Map<String, Object>} containing {@link Offer} metadata.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setMeta(final Map<String, Object> meta) {...}/*** Sets the language for this {@code Offer}.** @param language {@code List<String>} containing supported {@link Offer} language.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setLanguage(final List<String> language) {...}/*** Sets the characteristics for this {@code Offer}.** @param characteristics {@code Map<String, String>} containing {@link Offer} characteristics.* @return this Offer {@link Builder}* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Builder setCharacteristics(final Map<String, String> characteristics) {...}/*** Builds and returns the {@code Offer} object.** @return {@link Offer} object or null.* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.*/public Offer build() {...}}/*** Gets the {@code Offer} identifier.** @return {@link String} containing the {@link Offer} identifier.*/public String getId() {...}/*** Gets the {@code Offer} etag.** @return {@link String} containing the {@link Offer} etag.*/public String getEtag() {...}/*** Gets the {@code Offer} score.** @return {@code int} containing the {@link Offer} score.*/public int getScore() {...}/*** Gets the {@code Offer} schema.** @return {@link String} containing the {@link Offer} schema.*/public String getSchema() {...}/*** Gets the {@code Offer} metadata.** @return {@code Map<String, Object>} containing the {@link Offer} metadata.*/public Map<String, Object> getMeta() {...}/*** Gets the {@code Offer} type.** @return {@link OfferType} indicating the {@link Offer} type.*/public OfferType getType() {...}/*** Gets the {@code Offer} language.** @return {@code List<String>} containing the supported {@link Offer} language.*/public List<String> getLanguage() {...}/*** Gets the {@code Offer} content.** @return {@link String} containing the {@link Offer} content.*/public String getContent() {...}/*** Gets the {@code Offer} characteristics.** @return {@code Map<String, String>} containing the {@link Offer} characteristics.*/public Map<String, String> getCharacteristics() {...}/*** Gets the containing {@code OptimizeProposition} for this {@code Offer}.** @return {@link OptimizeProposition} instance.*/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 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 OptimizeProposition} offer.*/public void tapped() {...}/*** 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}.** 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 OptimizeProposition} 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 clipboard/// `Offer` class@objc(AEPOffer)public class Offer: NSObject, Codable {/// Unique Offer identifier@objc public let id: String/// Offer revision detail at the time of the request@objc public let etag: String/// Offer priority score@objc public let score: Double/// Offer schema string@objc public let schema: String/// Offer metadata@objc public let meta: [String: Any]?/// Offer type as represented in enum `OfferType`@objc public let type: OfferType/// Optional Offer language array@objc public let language: [String]?/// Offer content string@objc public let content: String/// Optional Offer characteristics dictionary@objc public let characteristics: [String: String]?}
The Offer
class extension provides methods for generating XDM data for Proposition Interactions field group which can be used for proposition tracking. It also contains direct methods for tracking proposition display and tap interactions.
Copied to your clipboard/// `Offer` extension@objcpublic 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./// If the proposition reference within the option is released and no longer valid, the method returns `nil`.////// - 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./// If the proposition reference within the option is released and no longer valid, the method returns `nil`.////// - 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]? {...}/// 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() {...}}
OfferType
An enum indicating the type of an offer, derived from the proposition item format
field in personalization query response.
Java
Copied to your clipboardpublic enum OfferType {UNKNOWN, JSON, TEXT, HTML, IMAGE;@Overridepublic String toString() {...}/*** Returns the {@code OfferType} for the given {@code format}.** @param format {@link String} containing the {@link Offer} format.* @return {@link OfferType} indicating the {@code Offer} format.*/public static OfferType from(final String format) {...}}
Swift
Copied to your clipboard/// Enum representing the supported Offer Types.public enum OfferType: Int, Codable {/// Unknown Offer typecase unknown = 0/// JSON Offercase json = 1/// Plain text Offercase text = 2/// Html Offercase html = 3/// Image Offercase image = 4/// Initializes OfferType with the provided format string./// - Parameter format: Offer format stringinit(from format: String) {...}}
Java
Copied to your clipboardpublic enum OfferType {UNKNOWN, JSON, TEXT, HTML, IMAGE;@Overridepublic String toString() {...}/*** Returns the {@code OfferType} for the given {@code format}.** @param format {@link String} containing the {@link Offer} format.* @return {@link OfferType} indicating the {@code Offer} format.*/public static OfferType from(final String format) {...}}
Swift
Copied to your clipboard/// Enum representing the supported Offer Types.public enum OfferType: Int, Codable {/// Unknown Offer typecase unknown = 0/// JSON Offercase json = 1/// Plain text Offercase text = 2/// Html Offercase html = 3/// Image Offercase image = 4/// Initializes OfferType with the provided format string./// - Parameter format: Offer format stringinit(from format: String) {...}}
AEPOptimizeError
This class represents the error details returned by the Edge Network while fetching propositions.
Kotlin
Error details received from Edge response along with AdobeError object returned with values:
- AdobeError.CALLBACK_TIMEOUT is returned when request timeout without any response.
- AdobeError.SERVER_ERROR is returned for HTTP Status 500.
- AdobeError.INVALID_REQUEST is returned for HTTP Status 400 - 499 (except 408 and 429).
Copied to your clipboardclass AEPOptimizeError(val type: String? = "",val status: Int? = 0,val title: String? = "",val detail: String? = "",var report: Map<String, Any>?,var adobeError: AdobeError?) {...}
Swift
Error details received from Edge response along with AEPError object returned with values:
- AEPError.callbackTimeout is returned when request timeout without any response.
- AEPError.serverErrors is returned for HTTP Status 500.
- AEPError.invalidRequest is returned for HTTP Status 400 - 499 (except 408 and 429).
Copied to your clipboard@objc(AEPOptimizeError)public class AEPOptimizeError: NSObject, Error {// This is a URI reference (RFC3986) that identifies the problem typepublic let type: String?// This is the HTTP status code generated by the server for this occurrence of the problem.public let status: Int?// This is a short, human-readable summary of the problem type.public let title: String?// This is human-readable description of the problem type.public let detail: String?// This is a map of additional properties that aid in debugging such as the request ID or the org ID. In some cases, it might contain data specific to the error at hand, such as a list of validation errors.public let report: [String: Any]?// This ia a mandatory AEPError representing the high level error statuspublic var aepError = AEPError.unexpected// Initializer for AEPOptimizeError based based on the Error details returned by Edge resposepublic init(type: String?, status: Int?, title: String?, detail: String?, aepError: AEPError? = nil) {...}}
Kotlin
Error details received from Edge response along with AdobeError object returned with values:
- AdobeError.CALLBACK_TIMEOUT is returned when request timeout without any response.
- AdobeError.SERVER_ERROR is returned for HTTP Status 500.
- AdobeError.INVALID_REQUEST is returned for HTTP Status 400 - 499 (except 408 and 429).
Copied to your clipboardclass AEPOptimizeError(val type: String? = "",val status: Int? = 0,val title: String? = "",val detail: String? = "",var report: Map<String, Any>?,var adobeError: AdobeError?) {...}
Swift
Error details received from Edge response along with AEPError object returned with values:
- AEPError.callbackTimeout is returned when request timeout without any response.
- AEPError.serverErrors is returned for HTTP Status 500.
- AEPError.invalidRequest is returned for HTTP Status 400 - 499 (except 408 and 429).
Copied to your clipboard@objc(AEPOptimizeError)public class AEPOptimizeError: NSObject, Error {// This is a URI reference (RFC3986) that identifies the problem typepublic let type: String?// This is the HTTP status code generated by the server for this occurrence of the problem.public let status: Int?// This is a short, human-readable summary of the problem type.public let title: String?// This is human-readable description of the problem type.public let detail: String?// This is a map of additional properties that aid in debugging such as the request ID or the org ID. In some cases, it might contain data specific to the error at hand, such as a list of validation errors.public let report: [String: Any]?// This ia a mandatory AEPError representing the high level error statuspublic var aepError = AEPError.unexpected// Initializer for AEPOptimizeError based based on the Error details returned by Edge resposepublic init(type: String?, status: Int?, title: String?, detail: String?, aepError: AEPError? = nil) {...}}