API Reference

clearPropositions

This API clears out the client-side in-memory propositions cache.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static void clearCachedPropositions()
Copied!
Example
1
Optimize.clearCachedPropositions();
Copied!

Swift

Syntax
1
static func clearCachedPropositions()
Copied!
Example
1
Optimize.clearCachedPropositions()
Copied!

Objective-C

Syntax
1
+ (void) clearCachedPropositions;
Copied!
Example
1
[AEPMobileOptimize clearCachedPropositions];
Copied!

extensionVersion

The extensionVersion() method (on Android) or the extensionVersion property (on iOS) returns the version information for currently installed AEPOptimize extension.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static String extensionVersion()
Copied!
Example
1
Optimize.extensionVersion();
Copied!

Swift

Syntax
1
static var extensionVersion: String
Copied!
Example
1
let extensionVersion = Optimize.extensionVersion
Copied!

Objective-C

Syntax
1
+ (nonnull NSString*) extensionVersion;
Copied!
Example
1
NSString *extensionVersion = [AEPMobileOptimize extensionVersion];
Copied!

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.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static void getPropositions(final List<DecisionScope> decisionScopes, final AdobeCallback<Map<DecisionScope, Proposition>> callback)
Copied!
  • 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, and if the operation times out or an error occurs in retrieving propositions, the fail method is invoked with the appropriate AdobeError.
Example
1
final DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);
2
final DecisionScope decisionScope2 = new DecisionScope("myScope");
3
4
final List<DecisionScope> decisionScopes = new ArrayList<>();
5
decisionScopes.add(decisionScope1);
6
decisionScopes.add(decisionScope2);
7
8
Optimize.getPropositions(scopes, new AdobeCallbackWithError<Map<DecisionScope, Proposition>>() {
9
@Override
10
public void fail(final AdobeError adobeError) {
11
// handle error
12
}
13
14
@Override
15
public void call(Map<DecisionScope, Proposition> propositionsMap) {
16
if (propositionsMap != null && !propositionsMap.isEmpty()) {
17
// get the propositions for the given decision scopes
18
if (propositionsMap.contains(decisionScope1)) {
19
final Proposition proposition1 = propsMap.get(decisionScope1)
20
// read proposition1 offers
21
}
22
if (propositionsMap.contains(decisionScope2)) {
23
final Proposition proposition2 = propsMap.get(decisionScope2)
24
// read proposition2 offers
25
}
26
}
27
}
28
});
Copied!

Swift

Syntax
1
static func getPropositions(for decisionScopes: [DecisionScope],
2
_ completion: @escaping ([DecisionScope: Proposition]?, Error?) -> Void)
Copied!
  • decisionScopes is an array of decision scopes for which propositions are requested.
  • completion is invoked with propositions dictionary of type [DecisionScope: Proposition]. An Error is returned if SDK fails to retrieve the propositions.
Example
1
let decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",
2
placementId: "xcore:offer-placement:1111111111111111"
3
itemCount: 2)
4
let decisionScope2 = DecisionScope(name: "myScope")
5
6
Optimize.getPropositions(for: [decisionScope1, decisionScope2]) { propositionsDict, error in
7
8
if let error = error {
9
// handle error
10
return
11
}
12
13
if let propositionsDict = propositionsDict {
14
// get the propositions for the given decision scopes
15
16
if let proposition1 = propositionsDict[decisionScope1] {
17
// read proposition1 offers
18
}
19
20
if let proposition2 = propositionsDict[decisionScope2] {
21
// read proposition2 offers
22
}
23
}
24
}
Copied!

Objective-C

Syntax
1
+ (void) getPropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopes
2
completion: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPProposition*>* _Nullable propositionsDict, NSError* _Nullable error)) completion;
Copied!
  • decisionScopes is an array of decision scopes for which propositions are requested.
  • completion is invoked with propositions dictionary of type NSDictionary<AEPDecisionScope*, AEPProposition*>. An NSError is returned if SDK fails to retrieve the propositions.
Example
1
AEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"
2
placementId: @"xcore:offer-placement:1111111111111111"
3
itemCount: 2];
4
AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];
5
6
[AEPMobileOptimize getPropositions: @[decisionScope1, decisionScope2]
7
completion: ^(NSDictionary<AEPDecisionScope*, AEPProposition*>* propositionsDict, NSError* error) {
8
if (error != nil) {
9
// handle error
10
return;
11
}
12
13
AEPProposition* proposition1 = propositionsDict[decisionScope1];
14
// read proposition1 offers
15
16
AEPProposition* proposition2 = propositionsDict[decisionScope2];
17
// read proposition2 offers
18
}];
Copied!

onPropositionsUpdate

This API registers a permanent callback which is invoked whenever the Edge extension dispatches a response Event received from the Experience Edge Network upon a personalization query. The personalization query requests can be triggered by the updatePropositions API, Edge extension sendEvent API or launch consequence rules.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static void onPropositionsUpdate(final AdobeCallback<Map<DecisionScope, Proposition>> callback)
Copied!
  • 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.
Example
1
Optimize.onPropositionsUpdate(new AdobeCallbackWithError<Map<DecisionScope, Proposition>>() {
2
@Override
3
public void fail(final AdobeError adobeError) {
4
// handle error
5
}
6
7
@Override
8
public void call(final Map<DecisionScope, Proposition> propositionsMap) {
9
if (propositionsMap != null && !propositionsMap.isEmpty()) {
10
// handle propositions
11
}
12
}
13
});
Copied!

Swift

Syntax
1
static func onPropositionsUpdate(perform action: @escaping ([DecisionScope: Proposition]?) -> Void)
Copied!
  • action is invoked with propositions dictionary of type [DecisionScope: Proposition].
Example
1
Optimize.onPropositionsUpdate { propositionsDict in
2
if let propositionsDict = propositionsDict {
3
// handle propositions
4
}
5
}
Copied!

Objective-C

Syntax
1
+ (void) onPropositionsUpdate: (void (^ _Nonnull)(NSDictionary<AEPDecisionScope*, AEPProposition*>* _Nullable)) action;
Copied!
  • action is invoked with propositions dictionary of type NSDictionary<AEPDecisionScope*, AEPProposition*>.
Example
1
[AEPMobileOptimize onPropositionsUpdate: ^(NSDictionary<AEPDecisionScope*, AEPProposition*>* propositionsDict) {
2
// handle propositions
3
}];
Copied!

registerExtension(s)

This API can be invoked to register the Optimize extension with the Mobile Core. On iOS, registerExtensions API is part of Mobile Core.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static void registerExtension()
Copied!
Example
1
Optimize.registerExtension();
Copied!

Swift

Syntax
1
static func registerExtensions(_ extensions: [NSObject.Type],
2
_ completion: (() -> Void)? = nil)
Copied!
  • extensions is an array of metatype of NSObject class from which all SDK extensions inherit.
  • completion is invoked when all the given extensions have been successfully registered with the SDK.
Example
1
MobileCore.registerExtensions([Optimize.self, ...]) {
2
// Processing upon registration completion
3
}
Copied!

Objective-C

Syntax
1
+ (void) registerExtensions: (NSArray<Class*>* _Nonnull) extensions
2
completion: (void (^ _Nullable)(void)) completion;
Copied!
  • extensions is an array of opaque type that represents an SDK extension class.
  • completion is invoked when all the given extensions have been successfully registered with the SDK.
Example
1
[AEPMobileCore registerExtensions:@[AEPMobileOptimize.class, ...] completion:^{
2
// Processing upon registration completion
3
}];
Copied!

resetIdentities

This MobileCore API can also be invoked to clear out the client-side data for the Optimize extension, such as the 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.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static void updatePropositions(final List<DecisionScope> decisionScopes, final Map<String, Object> xdm, final Map<String, Object> data)
Copied!
  • 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
1
Optimize.updatePropositions(new AdobeCallbackWithError<Map<DecisionScope, Proposition>>() {
2
@Override
3
public void fail(final AdobeError adobeError) {
4
// handle error
5
}
6
7
@Override
8
public void call(final Map<DecisionScope, Proposition> propositionsMap) {
9
if (propositionsMap != null && !propositionsMap.isEmpty()) {
10
// handle propositions
11
}
12
}
13
});
Copied!

Swift

Syntax
1
static func updatePropositions(for decisionScopes: [DecisionScope],
2
withXdm xdm: [String: Any]?,
3
andData data: [String: Any]? = nil)
Copied!
  • 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
1
let decisionScope1 = DecisionScope(activityId: "xcore:offer-activity:1111111111111111",
2
placementId: "xcore:offer-placement:1111111111111111"
3
itemCount: 2)
4
let decisionScope2 = DecisionScope(name: "myScope")
5
6
Optimize.updatePropositions(for: [decisionScope1, decisionScope2]
7
withXdm: ["xdmKey": "xdmValue"]
8
andData: ["dataKey": "dataValue"])
Copied!

Objective-C

Syntax
1
+ (void) updatePropositions: (NSArray<AEPDecisionScope*>* _Nonnull) decisionScopes
2
withXdm: (NSDictionary<NSString*, id>* _Nullable) xdm
3
andData: (NSDictionary<NSString*, id>* _Nullable) data;
Copied!
  • 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
1
AEPDecisionScope* decisionScope1 = [[AEPDecisionScope alloc] initWithActivityId: @"xcore:offer-activity:1111111111111111"
2
placementId: @"xcore:offer-placement:1111111111111111"
3
itemCount: 2];
4
AEPDecisionScope* decisionScope2 = [[AEPDecisionScope alloc] initWithName: @"myScope"];
5
6
[AEPMobileOptimize updatePropositions: @[decisionScope1, decisionScope2]
7
withXdm: @{@"xdmKey": @"xdmValue"}
8
andData: @{@"dataKey": @"dataValue"}];
Copied!

Public classes

Type
Android
(AEP 3.x) Swift
(AEP 3.x) Objective-C
class
DecisionScope
DecisionScope
AEPDecisionScope
class
Proposition
Proposition
AEPProposition
class
Offer
Offer
AEPOffer

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.
Android
iOS (AEP 3.x)
Java
1
/**
2
* {@code DecisionScope} class represents a scope used to fetch personalized offers from the Experience Edge network.
3
*/
4
public class DecisionScope {
5
6
/**
7
* Constructor creates a {@code DecisionScope} using the provided {@code name}.
8
*
9
* @param name {@link String} containing scope name.
10
*/
11
public DecisionScope(final String name) {...}
12
13
/**
14
* Constructor creates a {@code DecisionScope} using the provided {@code activityId} and {@code placementId}.
15
*
16
* This constructor assumes the item count for the given scope to be {@value #DEFAULT_ITEM_COUNT}.
17
*
18
* @param activityId {@link String} containing activity identifier for the given scope.
19
* @param placementId {@code String} containing placement identifier for the given scope.
20
*/
21
public DecisionScope(final String activityId, final String placementId) {...}
22
23
/**
24
* Constructor creates a {@code DecisionScope} using the provided {@code activityId} and {@code placementId}.
25
*
26
* @param activityId {@link String} containing activity identifier for the given scope.
27
* @param placementId {@code String} containing placement identifier for the given scope.
28
* @param itemCount {@code String} containing number of items to be returned for the given scope.
29
*/
30
public DecisionScope(final String activityId, final String placementId, final int itemCount) {...}
31
32
/**
33
* Gets the name for this scope.
34
*
35
* @return {@link String} containing the scope name.
36
*/
37
public String getName() {...}
38
}
Copied!
Swift
1
/// `DecisionScope` class is used to create decision scopes for personalization query requests to Experience Edge Network.
2
@objc(AEPDecisionScope)
3
public class DecisionScope: NSObject, Codable {
4
/// Decision scope name
5
@objc public let name: String
6
7
/// Creates a new decision scope using the given scope `name`.
8
///
9
/// - Parameter name: string representation for the decision scope.
10
@objc
11
public init(name: String) {...}
12
13
/// Creates a new decision scope using the given `activityId`, `placementId` and `itemCount`.
14
///
15
/// This initializer creates a scope name by Base64 encoding the JSON string created using the provided data.
16
///
17
/// If `itemCount` == 1, JSON string is
18
///
19
/// {"activityId":#activityId,"placementId":#placementId}
20
/// otherwise,
21
///
22
/// {"activityId":#activityId,"placementId":#placementId,"itemCount":#itemCount}
23
/// - Parameters:
24
/// - activityId: unique activity identifier for the decisioning activity.
25
/// - placementId: unique placement identifier for the decisioning activity offer.
26
/// - itemCount: number of offers to be returned from the server.
27
@objc
28
public convenience init(activityId: String, placementId: String, itemCount: UInt = 1) {...}
29
}
Copied!

Proposition

This class represents the decision propositions received from the decisioning services, upon a personalization query request to the Experience Edge network.
Android
iOS (AEP 3.x)
Java
1
public class Proposition {
2
3
/**
4
* Constructor creates a {@code Proposition} using the provided propostion {@code id}, {@code offers}, {@code scope} and {@code scopeDetails}.
5
*
6
* @param id {@link String} containing proposition identifier.
7
* @param offers {@code List<Offer>} containing proposition items.
8
* @param scope {@code String} containing encoded scope.
9
* @param scopeDetails {@code Map<String, Object>} containing scope details.
10
*/
11
Proposition(final String id, final List<Offer> offers, final String scope, final Map<String, Object> scopeDetails) {...}
12
13
/**
14
* Gets the {@code Proposition} identifier.
15
*
16
* @return {@link String} containing the {@link Proposition} identifier.
17
*/
18
public String getId() {...}
19
20
/**
21
* Gets the {@code Proposition} items.
22
*
23
* @return {@code List<Offer>} containing the {@link Proposition} items.
24
*/
25
public List<Offer> getOffers() {...}
26
27
/**
28
* Gets the {@code Proposition} scope.
29
*
30
* @return {@link String} containing the encoded {@link Proposition} scope.
31
*/
32
public String getScope() {...}
33
34
/**
35
* Gets the {@code Proposition} scope details.
36
*
37
* @return {@code Map<String, Object>} containing the {@link Proposition} scope details.
38
*/
39
public Map<String, Object> getScopeDetails() {...}
40
41
/**
42
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Reference} field group from this {@code Proposition}.
43
*
44
* The returned XDM data does not contain {@code eventType} for the Experience Event.
45
*
46
* @return {@code Map<String, Object>} containing the XDM data for the proposition reference.
47
*/
48
public Map<String, Object> generateReferenceXdm() {...}
49
}
Copied!
Swift
1
/// `Proposition` class
2
@objc(AEPProposition)
3
public class Proposition: NSObject, Codable {
4
5
/// Unique proposition identifier
6
@objc public let id: String
7
8
/// Array containing proposition decision options
9
@objc public lazy var offers: [Offer] = {...}()
10
11
/// Decision scope string
12
@objc public let scope: String
13
14
/// Scope details dictionary
15
@objc public var scopeDetails: [String: Any]
16
}
Copied!
The Proposition class extension provides a method for generating XDM data for Proposition Reference field group which can be used for proposition tracking.
Swift
1
/// `Proposition` extension
2
@objc
3
public extension Proposition {
4
/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Reference` field group from the given proposition.
5
///
6
/// 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.
7
///
8
/// - Note: The returned XDM data does not contain an `eventType` for the Experience Event.
9
/// - Returns A dictionary containing XDM data for the propositon reference.
10
func generateReferenceXdm() -> [String: Any] {...}
11
}
Copied!

Offer

This class represents the proposition option received from the decisioning services, upon a personalization query to the Experience Edge network.
Android
iOS (AEP 3.x)
Java
1
public class Offer {
2
3
/**
4
* {@code Offer} Builder.
5
*/
6
public static class Builder {
7
8
/**
9
* Builder constructor with required {@code Offer} attributes as parameters.
10
*
11
* It sets default values for remaining {@link Offer} attributes.
12
*
13
* @param id required {@link String} containing {@code Offer} identifier.
14
* @param type required {@link OfferType} indicating the {@code Offer} type.
15
* @param content required {@code String} containing the {@code Offer} content.
16
*/
17
public Builder(final String id, final OfferType type, final String content) {...}
18
19
/**
20
* Sets the etag for this {@code Offer}.
21
*
22
* @param etag {@link String} containing {@link Offer} etag.
23
* @return this Offer {@link Builder}
24
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
25
*/
26
public Builder setEtag(final String etag) {...}
27
28
/**
29
* Sets the score for this {@code Offer}.
30
*
31
* @param score {@code int} containing {@link Offer} score.
32
* @return this Offer {@link Builder}
33
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
34
*/
35
public Builder setScore(final int score) {...}
36
37
/**
38
* Sets the schema for this {@code Offer}.
39
*
40
* @param schema {@link String} containing {@link Offer} schema.
41
* @return this Offer {@link Builder}
42
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
43
*/
44
public Builder setSchema(final String schema) {...}
45
46
/**
47
* Sets the metadata for this {@code Offer}.
48
*
49
* @param meta {@code Map<String, Object>} containing {@link Offer} metadata.
50
* @return this Offer {@link Builder}
51
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
52
*/
53
public Builder setMeta(final Map<String, Object> meta) {...}
54
55
/**
56
* Sets the language for this {@code Offer}.
57
*
58
* @param language {@code List<String>} containing supported {@link Offer} language.
59
* @return this Offer {@link Builder}
60
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
61
*/
62
public Builder setLanguage(final List<String> language) {...}
63
64
/**
65
* Sets the characteristics for this {@code Offer}.
66
*
67
* @param characteristics {@code Map<String, String>} containing {@link Offer} characteristics.
68
* @return this Offer {@link Builder}
69
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
70
*/
71
public Builder setCharacteristics(final Map<String, String> characteristics) {...}
72
73
/**
74
* Builds and returns the {@code Offer} object.
75
*
76
* @return {@link Offer} object or null.
77
* @throws UnsupportedOperationException if this method is invoked after {@link Builder#build()}.
78
*/
79
public Offer build() {...}
80
}
81
82
/**
83
* Gets the {@code Offer} identifier.
84
*
85
* @return {@link String} containing the {@link Offer} identifier.
86
*/
87
public String getId() {...}
88
89
/**
90
* Gets the {@code Offer} etag.
91
*
92
* @return {@link String} containing the {@link Offer} etag.
93
*/
94
public String getEtag() {...}
95
96
/**
97
* Gets the {@code Offer} score.
98
*
99
* @return {@code int} containing the {@link Offer} score.
100
*/
101
public int getScore() {...}
102
103
/**
104
* Gets the {@code Offer} schema.
105
*
106
* @return {@link String} containing the {@link Offer} schema.
107
*/
108
public String getSchema() {...}
109
110
/**
111
* Gets the {@code Offer} metadata.
112
*
113
* @return {@code Map<String, Object>} containing the {@link Offer} metadata.
114
*/
115
public Map<String, Object> getMeta() {...}
116
117
/**
118
* Gets the {@code Offer} type.
119
*
120
* @return {@link OfferType} indicating the {@link Offer} type.
121
*/
122
public OfferType getType() {...}
123
124
/**
125
* Gets the {@code Offer} language.
126
*
127
* @return {@code List<String>} containing the supported {@link Offer} language.
128
*/
129
public List<String> getLanguage() {...}
130
131
/**
132
* Gets the {@code Offer} content.
133
*
134
* @return {@link String} containing the {@link Offer} content.
135
*/
136
public String getContent() {...}
137
138
/**
139
* Gets the {@code Offer} characteristics.
140
*
141
* @return {@code Map<String, String>} containing the {@link Offer} characteristics.
142
*/
143
public Map<String, String> getCharacteristics() {...}
144
145
/**
146
* Gets the containing {@code Proposition} for this {@code Offer}.
147
*
148
* @return {@link Proposition} instance.
149
*/
150
public Proposition getProposition() {...}
151
152
/**
153
* Dispatches an event for the Edge network extension to send an Experience Event to the Edge network with the display interaction data for the
154
* given {@code Proposition} offer.
155
*/
156
public void displayed() {...}
157
158
/**
159
* Dispatches an event for the Edge network extension to send an Experience Event to the Edge network with the tap interaction data for the
160
* given {@code Proposition} offer.
161
*/
162
public void tapped() {...}
163
164
/**
165
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code Proposition} item.
166
*
167
* The returned XDM data does contain the {@code eventType} for the Experience Event with value {@code decisioning.propositionDisplay}.
168
*
169
* 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
170
* dataset identifier.
171
*
172
* @return {@code Map<String, Object>} containing the XDM data for the proposition interaction.
173
*/
174
public Map<String, Object> generateDisplayInteractionXdm() {...}
175
176
/**
177
* Generates a map containing XDM formatted data for {@code Experience Event - Proposition Interactions} field group from this {@code Proposition} offer.
178
*
179
* The returned XDM data contains the {@code eventType} for the Experience Event with value {@code decisioning.propositionInteract}.
180
*
181
* 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
182
* dataset identifier.
183
*
184
* @return {@code Map<String, Object>} containing the XDM data for the proposition interaction.
185
*/
186
public Map<String, Object> generateTapInteractionXdm() {...}
187
188
}
Copied!
Swift
1
/// `Offer` class
2
@objc(AEPOffer)
3
public class Offer: NSObject, Codable {
4
/// Unique Offer identifier
5
@objc public let id: String
6
7
/// Offer revision detail at the time of the request
8
@objc public let etag: String
9
10
/// Offer priority score
11
@objc public let score: Int
12
13
/// Offer schema string
14
@objc public let schema: String
15
16
/// Offer metadata
17
@objc public let meta: [String: Any]?
18
19
/// Offer type as represented in enum `OfferType`
20
@objc public let type: OfferType
21
22
/// Optional Offer language array
23
@objc public let language: [String]?
24
25
/// Offer content string
26
@objc public let content: String
27
28
/// Optional Offer characteristics dictionary
29
@objc public let characteristics: [String: String]?
30
}
Copied!
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.
Swift
1
/// `Offer` extension
2
@objc
3
public extension Offer {
4
/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Interactions` field group from the given proposition option.
5
///
6
/// 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.
7
/// If the proposition reference within the option is released and no longer valid, the method returns `nil`.
8
///
9
/// - Note: The returned XDM data also contains the `eventType` for the Experience Event with value `decisioning.propositionDisplay`.
10
/// - Returns A dictionary containing XDM data for the propositon interactions.
11
func generateDisplayInteractionXdm() -> [String: Any]? {...}
12
13
/// Creates a dictionary containing XDM formatted data for `Experience Event - Proposition Interactions` field group from the given proposition option.
14
///
15
/// 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.
16
/// If the proposition reference within the option is released and no longer valid, the method returns `nil`.
17
///
18
/// - Note: The returned XDM data also contains the `eventType` for the Experience Event with value `decisioning.propositionInteract`.
19
/// - Returns A dictionary containing XDM data for the propositon interactions.
20
func generateTapInteractionXdm() -> [String: Any]? {...}
21
22
/// 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.
23
func displayed() {...}
24
25
/// 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.
26
func tapped() {...}
27
}
Copied!

OfferType

An enum indicating the type of an offer, derived from the proposition item format field in personalization query response.
Android
iOS (AEP 3.x)
Java
1
public enum OfferType {
2
UNKNOWN, JSON, TEXT, HTML, IMAGE;
3
4
@Override
5
public String toString() {...}
6
7
/**
8
* Returns the {@code OfferType} for the given {@code format}.
9
*
10
* @param format {@link String} containing the {@link Offer} format.
11
* @return {@link OfferType} indicating the {@code Offer} format.
12
*/
13
public static OfferType from(final String format) {...}
14
}
Copied!
Swift
1
/// Enum representing the supported Offer Types.
2
public enum OfferType: Int, Codable {
3
4
/// Unknown Offer type
5
case unknown = 0
6
7
/// JSON Offer
8
case json = 1
9
10
/// Plain text Offer
11
case text = 2
12
13
/// Html Offer
14
case html = 3
15
16
/// Image Offer
17
case image = 4
18
19
/// Initializes OfferType with the provided format string.
20
/// - Parameter format: Offer format string
21
init(from format: String) {...}
22
}
Copied!