Target API reference (deprecated in 2.x)
These deprecated APIs are present in ACPTarget 2.x only.

Using the prefetch APIs

The prefetchContent API signature has changed. We recommend that you use parameters encapsulated in TargetParameters.
Android
iOS

Java

Using the TargetPrefetch builder

The TargetPrefetch builder helps create a TargetPrefetch instance with the specified data. The returned instance can be used with prefetchContent, which accepts a TargetPrefetch object list to prefetch offers for the specified mbox locations.

Syntax

1
TargetPrefetch prefetchRequest = new TargetPrefetch.Builder("mboxName")
2
.setMboxParameters(new HashMap<String, String>())
3
.setOrderParameters(new HashMap<String, Object>())
4
.setProductParameters(new HashMap<String, String>())
5
.build();
Copied!

Using prefetchContent

Sends a prefetch request to your configured Target server with the TargetPrefetch list and specified profileParameters. The callback is invoked when the prefetch is complete, which returns a success status for the prefetch request.

Syntax

1
public static void prefetchContent(final List<TargetPrefetch> targetPrefetchList,
2
final Map<String, Object> profileParameters,
3
final AdobeCallback<Boolean> callback);
Copied!

Example

1
// first prefetch request
2
Map<String, Object> mboxParameters1 = new HashMap<>();
3
mboxParameters1.put("status", "platinum");
4
5
// second prefetch request
6
Map<String, Object> mboxParameters2 = new HashMap<>();
7
mboxParameters2.put("userType", "paid");
8
9
List<String> purchasedIds = new ArrayList<String>();
10
purchasedIds.add("34");
11
purchasedIds.add("125");
12
13
Map<String, Object> orderParameters2 = new HashMap<>();
14
orderParameters2.put("id", "ADCKKIM");
15
orderParameters2.put("total", "344.30");
16
orderParameters2.put("purchasedProductIds", purchasedIds);
17
18
Map<String, Object> productParameters2 = new HashMap<>();
19
productParameters2.put("id", "24D3412");
20
productParameters2.put("categoryId","Books");
21
22
TargetPrefetch prefetchRequest1 = new TargetPrefetch.Builder("mboxName1")
23
.setMboxParameters(mboxParameters1)
24
.build();
25
26
27
TargetPrefetch prefetchRequest2 = new TargetPrefetch.Builder("mboxName2")
28
.setMboxParameters(mboxParameters2)
29
.setOrderParameters(orderParameters2)
30
.setProductParameters(productParameters2)
31
.build();
32
33
34
List<TargetPrefetchObject> prefetchMboxesList = new ArrayList<>();
35
prefetchMboxesList.add(prefetchRequest1);
36
prefetchMboxesList.add(prefetchRequest2);
37
38
39
// Call the prefetchContent API.
40
Target.prefetchContent(prefetchMboxesList, profileParameters, prefetchStatusCallback);
Copied!

prefetchContent

Objective C

Use prefetchContent to send a prefetch request to your configured Target server with the ACPTargetPrefetchObject array and specified profileParameters. The callback will be invoked when the prefetch is complete, which returns a success status for the prefetch request.

Syntax

1
+ (void) prefetchContent: (nonnull NSArray<ACPTargetPrefetchObject*>*) targetPrefetchObjectArray
2
withProfileParameters: (nullable NSDictionary<NSString*, NSString*>*) profileParameters
3
callback: (nullable void (^) (BOOL success)) callback;
Copied!

Example

1
NSDictionary *mboxParameters1 = @{@"status":@"platinum"};
2
NSDictionary *productParameters1 = @{@"id":@"24D3412",
3
@"categoryId":@"Books"};
4
NSDictionary *orderParameters1 = @{@"id":@"ADCKKIM",
5
@"total":@"344.30",
6
@"purchasedProductIds":@"34, 125, 99"};
7
8
NSDictionary *mboxParameters2 = @{@"userType":@"Paid"};
9
NSDictionary *productParameters2 = @{@"id":@"764334",
10
@"categoryId":@"Online"};
11
NSArray *purchaseIDs = @[@"id1",@"id2"];
12
NSDictionary *orderParameters2 = @{@"id":@"4t4uxksa",
13
@"total":@"54.90",
14
@"purchasedProductIds":purchaseIDs};
15
16
// Creating Prefetch Objects
17
ACPTargetPrefetchObject *prefetch1 = [ACPTargetPrefetchObject prefetchObjectWithName:@"logo" mboxParameters:mboxParameters1];
18
prefetch1.productParameters = productParameters1;
19
prefetch1.orderParameters = orderParameters1;
20
21
ACPTargetPrefetchObject *prefetch2 = [ACPTargetPrefetchObject prefetchObjectWithName:@"buttonColor" mboxParameters:mboxParameters2];
22
prefetch2.productParameters = productParameters2;
23
prefetch2.orderParameters = orderParameters2;
24
25
// Creating prefetch Array
26
NSArray *prefetchArray = @[prefetch1,prefetch2];
27
28
// Creating Profile parameters
29
NSDictionary *profileParameters = @{@"age":@"20-32"};
30
31
// Target API Call
32
[ACPTarget prefetchContent:prefetchArray withProfileParameters:profileParameters callback:^(BOOL isSuccess){
33
// do something with the Boolean result
34
}];
Copied!

Load Target requests

Sends a batch request to your configured Target server for multiple mbox locations that are specified.
loadRequests API is deprecated and, for batch scenarios, has been replaced with retrieveLocationContent.
When working with prefetch APIs, and switching to the new retrieveLocationContent API, if you do not use locationsDisplayed, reporting will not work.
Android
iOS

TargetRequest Builder

TargetRequest builder helps create a TargetRequest instance. The returned instance can be used with loadRequests, which accepts a TargetRequest object list to retrieve offers for the specified mbox locations.

Syntax

1
TargetRequest request = new TargetRequest.Builder("mboxName","defaultContent")
2
.setMboxParameters(new HashMap<String, String>())
3
.setOrderParameters(new HashMap<String, Object>())
4
.setProductParameters(new HashMap<String, String>())
5
.setContentCallback(new AdobeCallback<String>() {
6
@Override
7
public void call(String value) {
8
// do something with target content.
9
}
10
}).build();
Copied!

loadRequests

Sends a batch request to your configured Target server for multiple mbox locations that are specified in the TargetRequest list. Each object in the array contains a callback function, which is invoked when content is available for its given mbox location.

Syntax

1
public static void loadRequests(final List<TargetRequest> requestArray,
2
final Map<String, Object> profileParameters);
Copied!

Example

1
// define parameters for first request
2
Map<String, Object> mboxParameters1 = new HashMap<>();
3
mboxParameters1.put("status", "platinum");
4
5
// define parameters for second request
6
Map<String, Object> mboxParameters2 = new HashMap<>();
7
mboxParameters2.put("userType", "paid");
8
9
List<String> purchasedIds = new ArrayList<String>();
10
purchasedIds.add("34");
11
purchasedIds.add("125");
12
13
Map<String, Object> orderParameters2 = new HashMap<>();
14
orderParameters2.put("id", "ADCKKIM");
15
orderParameters2.put("total", "344.30");
16
orderParameters2.put("purchasedProductIds", purchasedIds);
17
18
Map<String, Object> productParameters2 = new HashMap<>();
19
productParameters2.put("id", "24D3412");
20
productParameters2.put("categoryId","Books");
21
22
TargetRequest request1 = new TargetRequest.Builder("mboxName1", "defaultContent1")
23
.setMboxParameters(mboxParameters1)
24
.setContentCallback(new AdobeCallback<String>() {
25
@Override
26
public void call(String value) {
27
// do something with target content.
28
}
29
}).build();
30
31
TargetRequest request2 = new TargetRequest.Builder("mboxName2", "defaultContent2")
32
.setMboxParameters(mboxParameters2)
33
.setOrderParameters(orderParameters2)
34
.setProductParameters(productParameters2)
35
.setContentCallback(new AdobeCallback<String>() {
36
@Override
37
public void call(String value) {
38
// do something with target content.
39
}
40
}).build();
41
42
// Creating Array of Request Objects
43
List<TargetRequest> locationRequests = new ArrayList<>();
44
locationRequests.add(request1);
45
locationRequests.add(request2);
46
47
// Define the profile parameters map.
48
Map<String, Object> profileParameters = new HashMap<>();
49
profileParameters.put("ageGroup", "20-32");
50
51
// Call the targetLoadRequests API.
52
Target.loadRequests(locationRequests, profileParameters);
Copied!

loadRequests

Sends a batch request to your configured Target server for multiple mbox locations that are specified in theACPTargetRequestObject array. Each object in the array contains a callback function, which will be invoked when content is available for its given mbox location.

Syntax

1
+ (void) loadRequests: (nonnull NSArray<ACPTargetRequestObject*>*) requests
2
withProfileParameters: (nullable NSDictionary<NSString*, NSString*>*) profileParameters;
Copied!

Example

1
NSDictionary *mboxParameters1 = @{@"status":@"platinum"};
2
NSDictionary *productParameters1 = @{@"id":@"24D3412",
3
@"categoryId":@"Books"};
4
NSDictionary *orderParameters1 = @{@"id":@"ADCKKIM",
5
@"total":@"344.30",
6
@"purchasedProductIds":@"34, 125, 99"};
7
8
NSDictionary *mboxParameters2 = @{@"userType":@"Paid"};
9
NSDictionary *productParameters2 = @{@"id":@"764334",
10
@"categoryId":@"Online"};
11
NSArray *purchaseIDs = @[@"id1",@"id2"];
12
NSDictionary *orderParameters2 = @{@"id":@"4t4uxksa",
13
@"total":@"54.90",
14
@"purchasedProductIds":purchaseIDs};
15
16
ACPTargetRequestObject *request1 = [ACPTargetRequestObject requestObjectWithName:@"logo" defaultContent:@"BlueWhale" mboxParameters:mboxParameters1 callback:^(NSString *content){
17
// do something with the received content
18
}];
19
request1.productParameters = productParameters1;
20
request1.orderParameters = orderParameters1;
21
22
23
ACPTargetRequestObject *request2 = [ACPTargetRequestObject requestObjectWithName:@"buttonColor" defaultContent:@"red" mboxParameters:mboxParameters2 callback:^(NSString *content){
24
// do something with the received content
25
}];
26
request2.productParameters = productParameters1;
27
request2.orderParameters = orderParameters1;
28
29
// create request object array
30
NSArray *requestArray = @[request1,request2];
31
32
// Creating Profile parameters
33
NSDictionary *profileParameters = @{@"age":@"20-32"};
34
35
// Call the API
36
[ACPTarget loadRequests:requestArray withProfileParameters:profileParameters];
Copied!

Send an mbox click notification

Sends a click notification to the configured Target server for a prefetched or regular mbox location. The click metric should be enabled for the provided location name in Target.
locationClicked API signature is changed and the recommended way is to use parameters encapsulated in TargetParameters
Android
iOS

locationClicked

If a notification is sent for a prefetched mbox, its contents should already have been requested with loadRequests, which indicates that the mbox was viewed.

Syntax

1
public static void locationClicked(final String mboxName,
2
final Map<String, String> mboxParameters
3
final Map<String, String> productParameters
4
final Map<String, Object> orderParameters
5
final Map<String, String> profileParameters);
Copied!

Example

1
// Define Mbox parameters
2
Map<String, Object> mboxParameters = new HashMap<>();
3
mboxParameters.put("membership", "prime");
4
5
// Define Product parameters
6
Map<String, Object> productParameters = new HashMap<>();
7
productParameters.put("id", "CEDFJC");
8
productParameters.put("categoryId","Electronics");
9
10
List<String> purchasedIds = new ArrayList<String>();
11
purchasedIds.add("81");
12
purchasedIds.add("123");
13
purchasedIds.add("190");
14
15
// Define Order parameters
16
Map<String, Object> orderParameters = new HashMap<>();
17
orderParameters.put("id", "NJJICK");
18
orderParameters.put("total", "650");
19
orderParameters.put("purchasedProductIds", purchasedIds);
20
21
// Creating Profile parameters
22
Map<String, Object> profileParameters = new HashMap<>();
23
profileParameters.put("ageGroup", "20-32");
24
25
Target.locationClicked("cartLocation", mboxParameters, productParameters, orderParameters, profileParameters);
Copied!

locationClicked

If a notification is sent for a prefetched mbox, its contents should already have been requested with loadRequests, which indicates that the mbox was viewed.

Syntax

1
+ (void) locationClickedWithName: (nonnull NSString*) name
2
mboxParameters: (nullable NSDictionary<NSString*, NSString*>*) mboxParameters
3
productParameters: (nullable NSDictionary<NSString*, NSString*>*) productParameters
4
orderParameters: (nullable NSDictionary*) orderParameters
5
profileParameters: (nullable NSDictionary<NSString*, NSString*>*) profileParameters;
Copied!

Example

1
// Define Mbox parameters
2
NSDictionary *mboxParameters = @{@"membership":@"prime"};
3
4
// Define Product parameters
5
NSDictionary *productParameters = @{@"id":@"CEDFJC",
6
@"categoryId":@"Electronics"};
7
// Define Order parameters
8
NSDictionary *orderParameters = @{@"id":@"NJJICK",
9
@"total":@"650",
10
@"purchasedProductIds":@"81, 123, 190"};
11
12
// Define Profile parameters
13
NSDictionary *profileParameters = @{@"ageGroup":@"20-32"};
14
15
[ACPTarget locationClickedWithName:@"cartLocation"
16
mboxParameters:mboxParameters
17
productParameters:productParameters
18
orderParameters:orderParameters
19
profileParameters:profileParameters];
Copied!

Public classes

Android
iOS

TargetRequest

Using Builder to construct TargetRequest Object has been deprecated, and constructors are preferred way.
Here is a code sample for this class in Android:
1
public class TargetRequest extends TargetObject {
2
3
/**
4
* Builder used to construct a TargetRequest object.
5
*/
6
@Deprecated
7
public static class Builder {
8
private TargetRequest targetRequest;
9
10
/**
11
* Create a TargetRequest Builder.
12
*
13
* @param mboxName String mbox name for this request
14
* @param defaultContent String default content for this request
15
*/
16
@Deprecated
17
public Builder(final String mboxName, final String defaultContent);
18
19
/**
20
* Set mbox parameters for this request.
21
*
22
* @param mboxParameters Map<String, String> mbox parameters
23
* @return this builder
24
*/
25
public Builder setMboxParameters(final Map<String, String> mboxParameters);
26
27
/**
28
* Set order parameters for this request.
29
*
30
* @param orderParameters Map<String, Object> order parameters
31
* @return this builder
32
*/
33
public Builder setOrderParameters(final Map<String, Object> orderParameters);
34
35
/**
36
* Set profile parameters for this request.
37
*
38
* @param productParameters Map<String, String> product parameters
39
* @return this builder
40
*/
41
public Builder setProductParameters(final Map<String, String> productParameters);
42
43
/**
44
* Set profile parameters for this request.
45
*
46
* @param profileParameters Map<String, String> profile parameters
47
* @return this builder
48
*/
49
public Builder setProfileParameters(final Map<String, Object> profileParameters);
50
51
/**
52
* Set Target parameters for this request.
53
*
54
* @param targetParameters TargetParameters object
55
* @return this builder
56
*/
57
public Builder setTargetParameters(final TargetParameters targetParameters);
58
59
/**
60
* Set the callback function for this request.
61
*
62
* @param contentCallback AdobeCallback<String> which will get called with the returning content
63
* @return this builder
64
*/
65
public Builder setContentCallback(final AdobeCallback<String> contentCallback);
66
67
/**
68
* Build the TargetRequest.
69
*
70
* @return TargetRequest the target request object
71
*/
72
public TargetRequest build();
73
}
74
}
Copied!

TargetPrefetch

Using Builder to construct TargetPrefetch Object has been deprecated, and constructors are preferred way.
Here is a code sample for this class in Android:
1
public class TargetPrefetch extends TargetObject {
2
3
/**
4
* Builder used to construct a TargetPrefetch object
5
*/
6
@Deprecated
7
public static class Builder {
8
private TargetPrefetch targetPrefetch;
9
10
/**
11
* Create a TargetPrefetch Builder.
12
*
13
* @param mboxName String mbox name for this request
14
*/
15
public Builder(final String mboxName);
16
17
/**
18
* Set mbox parameters for this request.
19
*
20
* @param mboxParameters Map<String, String> mbox parameters
21
* @return this builder
22
*/
23
public Builder setMboxParameters(final Map<String, String> mboxParameters);
24
25
/**
26
* Set order parameters for this request.
27
*
28
* @param orderParameters Map<String, String> order parameters
29
* @return this builder
30
*/
31
public Builder setOrderParameters(final Map<String, Object> orderParameters);
32
33
/**
34
* Set product parameters for this request.
35
*
36
* @param productParameters Map<String, String> product parameters
37
* @return this builder
38
*/
39
public Builder setProductParameters(final Map<String, String> productParameters);
40
41
/**
42
* Set profile parameters for this request.
43
*
44
* @param profileParameters Map<String, String> profile parameters
45
* @return this builder
46
*/
47
public Builder setProfileParameters(final Map<String, Object> profileParameters);
48
49
/**
50
* Set Target parameters for this request.
51
*
52
* @param targetParameters TargetParameters object
53
* @return this builder
54
*/
55
public Builder setTargetParameters(final TargetParameters targetParameters);
56
57
/**
58
* Build and return TargetPrefetch
59
*
60
* @return TargetPrefetch the target prefetch object
61
*/
62
public TargetPrefetch build();
63
}
64
65
}
Copied!

ACPTargetRequestObject

This class extends ACPTargetPrefetchObject by adding default content and a function pointer property that will be used as a callback when requesting content from Target:
1
@interface ACPTargetRequestObject : ACPTargetPrefetchObject
2
3
///< The default content that will be returned if Target servers are unreachable
4
@property(nonatomic, strong, nonnull) NSString* defaultContent;
5
6
///< Optional. When batch requesting Target locations, callback will be invoked when content is available for this location.
7
@property(nonatomic, strong, nullable) void (^callback)(NSString* __nullable content);
8
@end
Copied!
The following method can be used to create an instance of a Target prefetch object that might be used to make a batch request to the configured Target server to prefetch content for mbox locations:
1
+ (nonnull instancetype) requestObjectWithName: (nonnull NSString*) name
2
defaultContent: (nonnull NSString*) defaultContent
3
mboxParameters: (nullable NSDictionary<NSString*, NSString*>*) mboxParameters
4
callback: (nullable void (^) (NSString* __nullable content)) callback;
Copied!

ACPTargetPrefetchObject

This class contains the name of the Target location/mbox and parameter dictionary for mbox parameters, product parameters, and order parameters that will be used in a prefetch:
1
@interface ACPTargetPrefetchObject : NSObject
2
3
///< The name of the Target location/mbox
4
@property(nonatomic, strong, nullable) NSString* name;
5
6
///< Dictionary containing key-value pairs of mbox parameters
7
@property(nonatomic, strong, nullable) NSDictionary<NSString*, NSString*>* mboxParameters;
8
9
///< Dictionary containing key-value pairs of product parameters
10
@property(nonatomic, strong, nullable) NSDictionary<NSString*, NSString*>* productParameters;
11
12
///< Dictionary containing key-value pairs of order parameters
13
@property(nonatomic, strong, nullable) NSDictionary* orderParameters;
14
@end
Copied!
The following method can be used to create an instance of a Target prefetch object that might be used to make a batch request to the configured Target server to prefetch content for mbox locations:
1
+ (nonnull instancetype) prefetchObjectWithName: (nonnull NSString*) name
2
mboxParameters: (nullable NSDictionary*) mboxParameters;
Copied!
Last modified 1mo ago