Target API reference

Target API reference

clearPrefetchCache

This API clears the in-memory cache that contains the prefetched offers.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void clearPrefetchCache()
Copied!
Example
1
Target.clearPrefetchCache();
Copied!
Syntax
1
static func clearPrefetchCache()
Copied!
Example
Swift
1
Target.clearPrefetchCache()
Copied!
Objective-C
1
[AEPMobileTarget clearPrefetchCache];
Copied!
Syntax
1
+ (void) clearPrefetchCache;
Copied!
Example
Swift
1
ACPTarget.clearPrefetchCache
Copied!
Objective-C
1
[ACPTarget clearPrefetchCache];
Copied!
Signature
1
clearPrefetchCache();
Copied!
Example usage
1
ACPTarget.clearPrefetchCache();
Copied!

clickedLocation

This API sends a location click notification for an mbox to the configured Target server and can be invoked in the following cases:
  • For a prefetched mbox, after the mbox content is retrieved using the retrieveLocationContent API.
  • For a regular mbox, where no previous prefetch request is made, and the mbox content is retrieved using the retrieveLocationContent API.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void locationClicked(final String mboxName, final TargetParameters parameters)
Copied!
  • mboxName is a String that contains the mbox location for which the click notification will be sent to Target.
  • parameters is the configured TargetParameters for the request.
Example
1
// Mbox parameters
2
Map<String, String> mboxParameters = new HashMap<>();
3
mboxParameters.put("membership", "prime");
4
5
// Product parameters
6
TargetProduct targetProduct = new TargetProduct("CEDFJC", "Electronics");
7
8
9
// Order parameters
10
List<String> purchasedIds = new ArrayList<String>();
11
purchasedIds.add("81");
12
purchasedIds.add("123");
13
purchasedIds.add("190");
14
TargetOrder targetOrder = new TargetOrder("NJJICK", "650", purchasedIds);
15
16
// Profile parameters
17
Map<String, String> profileParameters = new HashMap<>();
18
profileParameters.put("ageGroup", "20-32");
19
20
// Create Target Parameters
21
TargetParameters targetParameters = new TargetParameters.Builder(mboxParameters)
22
.profileParameters(profileParameters)
23
.order(targetOrder)
24
.product(targetProduct)
25
.build();
26
27
Target.locationClicked("cartLocation", targetParameters);
Copied!
Syntax
1
static func clickedLocation(_ name: String, targetParameters: TargetParameters?)
Copied!
  • name : a String that contains the mbox location for which the click notification will be sent to Target.
  • targetParameters : the configured TargetParameters for the request.
Example
Swift
1
Target.clickedLocation("aep-loc-1", targetParameters: TargetParameters(parameters: ["mbox_parameter_key": "mbox_parameter_value"], profileParameters: ["name": "Smith"], order: TargetOrder(id: "id1", total: 1.0, purchasedProductIds: ["ppId1"]), product: TargetProduct(productId: "pId1", categoryId: "cId1")))
Copied!
Objective-C
1
AEPTargetOrder *order = [[AEPTargetOrder alloc] initWithId:@"id1" total:1.0 purchasedProductIds:@[@"ppId1"]];
2
AEPTargetProduct *product =[[AEPTargetProduct alloc] initWithProductId:@"pId1" categoryId:@"cId1"];
3
AEPTargetParameters * targetParams = [[AEPTargetParameters alloc] initWithParameters:@{@"mbox_parameter_key":@"mbox_parameter_value"} profileParameters:@{@"name":@"Smith"} order:order product:product];
4
[AEPMobileTarget clickedLocation:@"aep-loc-1" withTargetParameters:targetParams];
Copied!
Syntax
1
+ (void) locationClickedWithName: (nonnull NSString*) name targetParameters: (nullable ACPTargetParameters*) parameters;
Copied!
  • name is an NSString that contains the mbox location for which the click notification will be sent to Target.
  • parameters is the configured ACPTargetParameters for the request.
Example
Swift
1
// Mbox parameters
2
let mboxParameters = [
3
"membership": "prime"
4
]
5
6
// Product parameters
7
let productParameters = [
8
"id": "CEDFJC",
9
"categoryId": "Electronics"
10
]
11
12
// Order parameters
13
let orderParameters = [
14
"id": "NJJICK",
15
"total": "650",
16
"purchasedProductIds": "81, 123, 190"
17
]
18
19
// Profile parameters
20
let profileParameters = [
21
"ageGroup": "20-32"
22
]
23
24
// Create Target parameters
25
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
26
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
27
let targetParameters = ACPTargetParameters(parameters: nil, profileParameters: nil, product: product, order: order)
28
29
ACPTarget.locationClicked(withName: "cartLocation", targetParameters: targetParameters)
Copied!
Objective-C
1
// Mbox parameters
2
NSDictionary *mboxParameters = @{@"membership":@"prime"};
3
4
// Product parameters
5
NSDictionary *productParameters = @{@"id":@"CEDFJC",
6
@"categoryId":@"Electronics"};
7
// Order parameters
8
NSDictionary *orderParameters = @{@"id":@"NJJICK",
9
@"total":@"650",
10
@"purchasedProductIds":@"81, 123, 190"};
11
12
// Profile parameters
13
NSDictionary *profileParameters = @{@"ageGroup":@"20-32"};
14
15
// Create Target parameters
16
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
17
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
18
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:nil
19
profileParameters:nil
20
product:product
21
order:order];
22
23
[ACPTarget locationClickedWithName:@"cartLocation" targetParameters:targetParameters];
Copied!
Syntax
1
locationClickedWithName(name: string, parameters?: ACPTargetParameters)
Copied!
  • name is a string that contains the mbox location for which the click notification will be sent to Target.
  • parameters is the configured ACPTargetParameters for the request.
Example
1
// Mbox parameters
2
var mboxParameters = {"membership": "prime"};
3
4
// Product parameters
5
var productParameters = new ACPTargetProduct("CEDFJC", "Electronics");
6
7
// Order parameters
8
var orderParameters = new ACPTargetOrder("NJJICK", 650, ["81","123","190"]);
9
10
// Profile parameters
11
var profileParameters = {"ageGroup": "20-32"};
12
13
// Create Target parameters
14
var product = new ACPTargetProduct("24D334", "Stationary");
15
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);
16
var targetParameters = new ACPTargetParameters(null, null, product, order);
17
18
ACPTarget.locationClickedWithName("cartLocation", targetParameters);
Copied!

displayedLocations

This API sends a location display notification for an mbox to the configured Target server. The API should be invoked for a prefetched mbox after the mbox content is retrieved using the retrieveLocationContent API. If no previous prefetch request is made, and the mbox content is retrieved using the retrieveLocationContent API, calling this API does not trigger a notification request to the Target server.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void locationsDisplayed(final List<String> mboxNames, final TargetParameters targetParameters)
Copied!
  • mboxNames is a list of the mbox locations for which the display notification will be sent to Target.
  • targetParameters is the configured TargetParameters for the request.
Example
1
List<String> purchasedProductIds = new ArrayList<String>();
2
purchasedProductIds.add("34");
3
purchasedProductIds.add("125");
4
TargetOrder targetOrder = new TargetOrder("123", 567.89, purchasedProductIds);
5
6
TargetProduct targetProduct = new TargetProduct("123", "Books");
7
8
TargetParameters targetParameters = new TargetParameters.Builder()
9
.parameters(new HashMap<String, String>())
10
.profileParameters(new HashMap<String, String>())
11
.product(targetProduct)
12
.order(targetOrder)
13
.build();
14
15
List<String> mboxList = new ArrayList<>();
16
mboxList.add("mboxName1");
17
18
Target.locationsDisplayed(mboxList, targetParameters);
Copied!
Syntax
1
static func displayedLocations(_ names: [String], targetParameters: TargetParameters?)
Copied!
  • names : is an array of the mbox locations for which the display notification will be sent to Target.
  • targetParameters : is the configured TargetParameters for the request.
Example
Swift
1
Target.displayedLocations(
2
["mboxName1", "mboxName2"],
3
targetParameters: TargetParameters(
4
parameters: nil,
5
profileParameters: nil,
6
order: TargetOrder(id: "ADCKKBC", total: 400.50, purchasedProductIds: ["34", "125"]),
7
product: TargetProduct(productId: "24D334", categoryId: "Stationary")
8
)
9
)
Copied!
Objective-C
1
AEPTargetOrder *order = [[AEPTargetOrder alloc] initWithId:@"ADCKKBC" total:400.50 purchasedProductIds:@[@"34", @"125"]];
2
AEPTargetProduct *product =[[AEPTargetProduct alloc] initWithProductId:@"24D334" categoryId:@"Stationary"];
3
AEPTargetParameters * targetParams = [[AEPTargetParameters alloc] initWithParameters:nil profileParameters:nil order:order product:product];
4
[AEPMobileTarget displayedLocations:@[@"mboxName1", @"mboxName2"] withTargetParameters:targetParams];
Copied!
Syntax
1
+ (void) locationsDisplayed: (nonnull NSArray<NSString*>*) mboxNames
2
withTargetParameters: (nullable ACPTargetParameters*) targetParameters;
Copied!
  • mboxNames is an NSArray of the mbox locations for which the display notification will be sent to Target.
  • targetParameters is the configured ACPTargetParameters for the request.
Example
Swift
1
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
2
3
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
4
5
let targetParameters = ACPTargetParameters(parameters: nil, profileParameters: nil, product: product, order: order)
6
7
ACPTarget.locationsDisplayed(["mboxName1", "mboxName2"], with: targetParameters)
Copied!
Objective-C
1
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
2
3
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
4
5
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:nil
6
profileParameters:nil
7
product:product
8
order:order];
9
10
[ACPTarget locationsDisplayed:@[@"mboxName1", @"mboxName2"] withTargetParameters:targetParameters];
Copied!
Syntax
1
locationsDisplayed(mboxNames: Array<string>, parameters?: ACPTargetParameters)
Copied!
  • mboxNames is an Array of the mbox locations for which the display notification will be sent to Target.
  • targetParameters is the configured ACPTargetParameters for the request.
Example
1
var product = new ACPTargetProduct("24D334", "Stationary");
2
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34", "125"]);
3
var targetParameters = new ACPTargetParameters(null, null, product, order);
4
5
ACPTarget.locationsDisplayed(["mboxName1", "mboxName2"], targetParameters);
Copied!

extensionVersion

Returns the running version of the Target extension.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public String extensionVersion()
Copied!
Example
1
Target.extensionVersion();
Copied!
Syntax
1
static var extensionVersion: String
Copied!
Example
Swift
1
let targetVersion = Target.extensionVersion
Copied!
Objective-C
1
NSString *targetVersion = [AEPMobileTarget extensionVersion];
Copied!
Syntax
1
+ (nonnull NSString*) extensionVersion;
Copied!
Example
Swift
1
let targetVersion = ACPTarget.extensionVersion()
Copied!
Objective-C
1
NSString *targetVersion = [ACPTarget extensionVersion];
Copied!
Syntax
1
extensionVersion(): Promise<string>
Copied!
Example
1
ACPTarget.extensionVersion().then(version => {
2
// read Target extension version
3
});
Copied!

getThirdPartyId

This API gets the custom visitor ID for Target. If no third-party ID was previously set, or if the ID was reset by calling resetExperience API, it will have a nil value.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void getThirdPartyId(final AdobeCallback<String> callback)
Copied!
  • callback is invoked with the thirdPartyId value. If no third-party ID was set, this value will be null.
Example
1
Target.getThirdPartyId(new AdobeCallback<String>() {
2
@Override
3
public void call(String thirdPartyId) {
4
// read Target thirdPartyId
5
}
6
});
Copied!
Syntax
1
static func getThirdPartyId(_ completion: @escaping (String?, Error?) -> Void)
Copied!
  • completion : invoked with the thirdPartyId value. If no third-party ID was set, this value will be nil.
Example
Swift
1
Target.getThirdPartyId { (id, err) in
2
// read Target thirdPartyId
3
}
Copied!
Objective-C
1
[AEPMobileTarget getThirdPartyId:^(NSString *thirdPartyID, NSError *error){
2
// read Target thirdPartyId
3
}];
Copied!
Syntax
1
+ (void) getThirdPartyId: (nonnull void (^) (NSString* __nullable thirdPartyId)) callback;
Copied!
  • callback is invoked with the thirdPartyId value. If no third-party ID was set, this value will be nil.
Example
Swift
1
ACPTarget.getThirdPartyId({thirdPartyID in
2
// read Target thirdPartyId
3
})
Copied!
Objective-C
1
[ACPTarget getThirdPartyId:^(NSString *thirdPartyId){
2
// read Target thirdPartyId
3
}];
Copied!
Syntax
1
getThirdPartyId(): Promise<string>
Copied!
  • A Promise object is returned and is resolved with the thirdPartyId value.
Example
1
ACPTarget.getThirdPartyId().then(thirdPartyId => {
2
// read Target thirdPartyId
3
});
Copied!

getTntId

This API gets the Target user ID (also known as the tntId) from the Target service. The tntId is returned in the network response after a successful call to prefetchContent or retrieveLocationContent, which is then persisted in the SDK. This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall or when the resetExperience API is used.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void getTntId(final AdobeCallback<String> callback)
Copied!
  • callback is invoked with the tntId value. If no Target ID was set, this value will be null.
Example
1
Target.getTntId(new AdobeCallback<String>() {
2
@Override
3
public void call(String tntId) {
4
// read target's tntid
5
}
6
});
Copied!
Syntax
1
static func getTntId(_ completion: @escaping (String?, Error?) -> Void)
Copied!
  • completion : invoked with the tntId value. If no Target ID was set, this value will be nil.
Example
Swift
1
Target.getTntId({ (id, err) in
2
// read target's tntId
3
})
Copied!
Objective-C
1
[AEPMobileTarget getTntId:^(NSString *tntID, NSError *error){
2
// read target's tntId
3
}];
Copied!
Syntax
1
+ (void) getTntId: (nonnull void (^) (NSString* __nullable tntId)) callback;
Copied!
  • callback is invoked with the tntId value. If no Target ID was set, this value will be nil.
Example
Swift
1
ACPTarget.getTntId({tntId in
2
// read target's tntId
3
})
Copied!
Objective-C
1
[ACPTarget getTntId:^(NSString *tntId){
2
// read target's tntId
3
}];
Copied!
Syntax
1
getTntId(): Promise<string>
Copied!
  • A Promise object is returned and is resolved with the thirdPartyId value.
Example
1
ACPTarget.getTntId().then(tntId => {
2
// read target's tntId
3
});
Copied!

prefetchContent

This API sends a prefetch request to your configured Target server. The prefetch request is sent with the prefetch objects array and the specified Target parameters.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void prefetchContent(final List<TargetPrefetch> mboxPrefetchList, final TargetParameters parameters, final AdobeCallback<String> callback)
Copied!
  • mboxPrefetchList is a list of TargetPrefetch objects for various mbox locations.
  • parameters is the configured TargetParameters for the prefetch request.
  • If the prefetch is successful, callback is invoked with a null value. If the prefetch is not successful, an error message is returned.
Example
1
// first prefetch request
2
Map<String, String> mboxParameters1 = new HashMap<>();
3
mboxParameters1.put("status", "platinum");
4
5
TargetParameters targetParameters1 = new TargetParameters.Builder()
6
.parameters(mboxParameters1)
7
.build();
8
9
TargetPrefetch prefetchRequest1 = new TargetPrefetch("mboxName1", targetParameters1);
10
11
// second prefetch request
12
Map<String, String> mboxParameters2 = new HashMap<>();
13
mboxParameters2.put("userType", "paid");
14
15
List<String> purchasedIds = new ArrayList<String>();
16
purchasedIds.add("34");
17
purchasedIds.add("125");
18
TargetOrder targetOrder = new TargetOrder("ADCKKIM", 344.30, purchasedIds);
19
20
TargetProduct targetProduct = new TargetProduct("24D3412", "Books");
21
22
TargetParameters targetParameters2 = new TargetParameters.Builder()
23
.parameters(mboxParameters2)
24
.product(targetProduct)
25
.order(targetOrder)
26
.build();
27
28
TargetPrefetch prefetchRequest2 = new TargetPrefetch("mboxName2", targetParameters2);
29
30
List<TargetPrefetch> prefetchMboxesList = new ArrayList<>();
31
prefetchMboxesList.add(prefetchRequest1);
32
prefetchMboxesList.add(prefetchRequest2);
33
34
// Call the prefetchContent API.
35
TargetParamters targetParameters = null;
36
Target.prefetchContent(prefetchMboxesList, targetParameters, prefetchStatusCallback);
Copied!
Syntax
1
static func prefetchContent(_ prefetchArray: [TargetPrefetch], with targetParameters: TargetParameters? = nil, _ completion: ((Error?) -> Void)?)
Copied!
  • prefetchArray - is an array of TargetPrefetch objects for various mbox locations.
  • targetParameters - is the configured TargetParameters for the prefetch request.
  • If the prefetch is successful, completion is invoked with a nil value. If the prefetch is not successful, an error message is returned.
Example
Swift
1
let TargetParameters1 = TargetParameters(
2
parameters: ["status": "platinum"],
3
profileParameters: ["age": "20"],
4
order: TargetOrder(id: "ADCKKIM", total: 344.30, purchasedProductIds: ["34", "125"]),
5
product: TargetProduct(productId: "24D3412", categoryId:"Books")
6
)
7
8
let TargetParameters2 = TargetParameters(
9
parameters: ["userType": "Paid"],
10
profileParameters: nil,
11
order: TargetOrder(id: "ADCKKIM", total: 344.30, purchasedProductIds: ["id1", "id2"]),
12
product: TargetProduct(productId: "764334", categoryId:"Online")
13
)
14
15
let globalTargetParameters = TargetParameters(
16
parameters: ["status": "progressive"],
17
profileParameters: ["age": "20-32"],
18
order: TargetOrder(id: "ADCKKBC", total: 400.50, purchasedProductIds: ["34", "125"]),
19
product: TargetProduct(productId: "24D334", categoryId:"Stationary")
20
)
21
22
Target.prefetchContent([
23
TargetPrefetch(name: "mboxName1", targetParameters: TargetParameters1),
24
TargetPrefetch(name: "mboxName2", targetParameters: TargetParameters2),
25
],
26
with: globalTargetParameters
27
){ error in
28
// do something with the callback response
29
}
Copied!
Objective-C
1
NSDictionary *mboxParameters1 = @{@"status":@"platinum"};
2
NSDictionary *profileParameters1 = @{@"age":@"20"};
3
AEPTargetProduct *product1 = [[AEPTargetProduct alloc] initWithProductId:@"24D3412" categoryId:@"Books"];
4
AEPTargetOrder *order1 = [[AEPTargetOrder alloc] initWithId:@"ADCKKIM" total:[@(344.30) doubleValue] purchasedProductIds:@[@"34", @"125"]];
5
6
AEPTargetParameters *targetParameters1 = [[AEPTargetParameters alloc] initWithParameters:mboxParameters1 profileParameters:profileParameters1 order:order1 product:product1 ];
7
8
NSDictionary *mboxParameters2 = @{@"userType":@"Paid"};
9
AEPTargetProduct *product2 = [[AEPTargetProduct alloc] initWithProductId:@"764334" categoryId:@"Online"];
10
AEPTargetOrder *order2 = [[AEPTargetOrder alloc] initWithId:@"ADCKKIM" total:[@(344.30) doubleValue] purchasedProductIds:@[@"id1",@"id2"]];
11
AEPTargetParameters *targetParameters2 = [[AEPTargetParameters alloc] initWithParameters:mboxParameters2 profileParameters:nil order:order2 product:product2 ];
12
13
// Creating Prefetch Objects
14
AEPTargetPrefetchObject *prefetch1 = [[AEPTargetPrefetchObject alloc] initWithName: @"logo" targetParameters:targetParameters1];
15
AEPTargetPrefetchObject *prefetch2 = [[AEPTargetPrefetchObject alloc] initWithName: @"buttonColor" targetParameters:targetParameters2];
16
17
// Creating prefetch Array
18
NSArray *prefetchArray = @[prefetch1,prefetch2];
19
20
// Creating Target parameters
21
NSDictionary *mboxParameters = @{@"status":@"progressive"};
22
NSDictionary *profileParameters = @{@"age":@"20-32"};
23
AEPTargetProduct *product = [[AEPTargetProduct alloc] initWithProductId:@"24D334" categoryId:@"Stationary"];
24
AEPTargetOrder *order = [[AEPTargetOrder alloc] initWithId:@"ADCKKBC" total:[@(400.50) doubleValue] purchasedProductIds:@[@"34", @"125"]];
25
26
AEPTargetParameters *targetParameters = [[AEPTargetParameters alloc] initWithParameters:mboxParameters
27
profileParameters:profileParameters
28
order:order
29
product:product];
30
31
// Target API Call
32
[AEPMobileTarget prefetchContent:prefetchArray withParameters:targetParameters callback:^(NSError * _Nullable error){
33
// do something with the callback response
34
}];
Copied!
Syntax
1
+ (void) prefetchContent: (nonnull NSArray<ACPTargetPrefetchObject*>*) prefetchObjectArray
2
withParameters: (nullable ACPTargetParameters*) parameters
3
callback: (nullable void (^) (NSError* _Nullable error)) callback;
Copied!
Example
Swift
1
let mboxParameters1 = [
2
"status": "platinum"
3
]
4
let profileParameters1 = [
5
"age": "20"
6
]
7
let product1 = ACPTargetProduct(id: "24D3412", categoryId: "Books")
8
let order1 = ACPTargetOrder(id: "ADCKKIM", total: NSNumber(value: 344.30), purchasedProductIds: ["34", "125"])
9
10
let targetParameters1 = ACPTargetParameters(parameters: mboxParameters1, profileParameters: profileParameters1, product: product1, order: order1)
11
12
let mboxParameters2 = [
13
"userType": "Paid"
14
]
15
let product2 = ACPTargetProduct(id: "764334", categoryId: "Online")
16
let order2 = ACPTargetOrder(id: "ADCKKIM", total: NSNumber(value: 344.30), purchasedProductIds: ["id1", "id2"])
17
18
let targetParameters2 = ACPTargetParameters(parameters: mboxParameters2, profileParameters: nil, product: product2, order: order2)
19
20
// Creating Prefetch Objects
21
let prefetch1 = ACPTargetPrefetchObject(name: "logo", targetParameters: targetParameters1)
22
23
let prefetch2 = ACPTargetPrefetchObject(name: "buttonColor", targetParameters: targetParameters2)
24
25
// Creating prefetch Array
26
let prefetchArray = [prefetch1, prefetch2]
27
28
// Creating Target parameters
29
let mboxParameters = [
30
"status": "progressive"
31
]
32
let profileParameters = [
33
"age": "20-32"
34
]
35
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
36
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
37
38
let targetParameters = ACPTargetParameters(parameters: mboxParameters, profileParameters: profileParameters, product: product, order: order)
39
40
// Target API Call
41
ACPTarget.prefetchContent(prefetchArray, with: targetParameters, callback: { error in
42
// do something with the callback response
43
})
Copied!
Objective-C
1
NSDictionary *mboxParameters1 = @{@"status":@"platinum"};
2
NSDictionary *profileParameters1 = @{@"age":@"20"};
3
ACPTargetProduct *product1 = [ACPTargetProduct targetProductWithId:@"24D3412" categoryId:@"Books"];
4
ACPTargetOrder *order1 = [ACPTargetOrder targetOrderWithId:@"ADCKKIM" total:@(344.30) purchasedProductIds:@[@"34", @"125"]];
5
6
ACPTargetParameters *targetParameters1 = [ACPTargetParameters targetParametersWithParameters:mboxParameters1
7
profileParameters:profileParameters1
8
product:product1
9
order:order1];
10
11
NSDictionary *mboxParameters2 = @{@"userType":@"Paid"};
12
ACPTargetProduct *product2 = [ACPTargetProduct targetProductWithId:@"764334" categoryId:@"Online"];
13
ACPTargetOrder *order2 = [ACPTargetOrder targetOrderWithId:@"ADCKKIM" total:@(344.30) purchasedProductIds:@[@"id1",@"id2"]];
14
15
ACPTargetParameters *targetParameters2 = [ACPTargetParameters targetParametersWithParameters:mboxParameters2
16
profileParameters:nil
17
product:product2
18
order:order2];
19
20
// Creating Prefetch Objects
21
ACPTargetPrefetchObject *prefetch1 = [ACPTargetPrefetchObject targetPrefetchObjectWithName:@"logo"
22
targetParameters:targetParameters1];
23
24
ACPTargetPrefetchObject *prefetch2 = [ACPTargetPrefetchObject targetPrefetchObjectWithName:@"buttonColor"
25
targetParameters:targetParameters2];
26
27
// Creating prefetch Array
28
NSArray *prefetchArray = @[prefetch1,prefetch2];
29
30
// Creating Target parameters
31
NSDictionary *mboxParameters = @{@"status":@"progressive"};
32
NSDictionary *profileParameters = @{@"age":@"20-32"};
33
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
34
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
35
36
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:mboxParameters
37
profileParameters:profileParameters
38
product:product
39
order:order];
40
41
// Target API Call
42
[ACPTarget prefetchContent:prefetchArray withParameters:targetParameters callback:^(NSError * _Nullable error){
43
// do something with the callback response
44
}];
Copied!
Syntax
1
prefetchContent(prefetchObjectArray: Array<ACPTargetPrefetchObject>, parameters?: ACPTargetParameters): Promise<any>
Copied!
  • prefetchObjectArray is an Array of ACPTargetPrefetchObject objects for various mbox locations.
  • parameters is the configured ACPTargetParameters for the prefetch request.
  • A Promise object is returned and is resolved with true value or is rejected with the reason for the error.
Example
1
var mboxParameters1 = {"status": "platinum"};
2
var profileParameters1 = {"age": "20"};
3
var product1 = new ACPTargetProduct("24D3412", "Books");
4
var order1 = new ACPTargetOrder("ADCKKIM", 344.30, ["34","125"]);
5
var targetParameters1 = new ACPTargetParameters(mboxParameters1, profileParameters1, product1, order1);
6
7
var mboxParameters2 = {"userType": "Paid"};
8
var product2 = new ACPTargetProduct("764334", "Online");
9
var order2 = new ACPTargetOrder("ADCKKIM", 344.30, ["id1","id2"]);
10
var targetParameters2 = new ACPTargetParameters(mboxParameters2, null, product2, order2);
11
12
// Creating Prefetch Objects
13
var prefetch1 = new ACPTargetPrefetchObject("logo", targetParameters1);
14
var prefetch2 = new ACPTargetPrefetchObject("buttonColor", targetParameters2);
15
16
// Creating prefetch Array
17
var prefetchList = [prefetch1, prefetch2];
18
19
// Creating Target parameters
20
var mboxParameters = {"status": "progressive"};
21
var profileParameters = {"age": "20-32"};
22
var product = new ACPTargetProduct("24D334", "Stationary");
23
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);
24
var targetParameters = new ACPTargetParameters(mboxParameters, profileParameters, product, order);
25
26
// Target API Call
27
ACPTarget.prefetchContent(prefetchList, targetParameters).then(success => console.log(success)).catch(err => console.log(err));
Copied!

registerExtension

Registers the Target extension with the Mobile Core.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void registerExtension()
Copied!
Example
1
Target.registerExtension();
Copied!
This API no longer exists in Target. Instead, the extension should be registered by calling the registerExtensions API in the MobileCore. Please see the updated SDK initialization steps at the migrate to Swift tutorial.
Syntax
1
+ (void) registerExtension;
Copied!
Example
Swift
1
ACPTarget.registerExtension()
Copied!
Objective-C
1
[ACPTarget registerExtension];
Copied!
When using React Native, register the Target extension with Mobile Core in native code as shown on the Android and iOS tabs.

resetExperience

This API resets the user's experience by removing the visitor identifiers and resetting the Target session. Invoking this API also removes previously set Target user ID and custom visitor IDs, Target Edge Host, and the session information from persistent storage.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void resetExperience()
Copied!
Example
1
Target.resetExperience();
Copied!
Syntax
1
static func resetExperience()
Copied!
Example
Swift
1
Target.resetExperience()
Copied!
Objective-C
1
[AEPMobileTarget resetExperience];
Copied!
Syntax
1
+ (void) resetExperience;
Copied!
Example
Swift
1
ACPTarget.resetExperience()
Copied!
Objective-C
1
[ACPTarget resetExperience];
Copied!
Syntax
1
resetExperience()
Copied!
Example
1
ACPTarget.resetExperience();
Copied!

retrieveLocationContent

This API sends a batch request to the configured Target server for multiple mbox locations.
A request will be sent to the configured Target server for mbox locations in the requests array for Target requests that have not been previously prefetched. The content for the mbox locations that have been prefetched in a previous request are returned from the SDK, and no additional network request is made. Each Target request object in the list contains a callback function, which is invoked when content is available for its given mbox location.
When using contentWithData callback to instantiate TargetRequest object, the following keys can be used to read response tokens and Analytics for Target (A4T) info from the data payload, if available in the Target response.
  • responseTokens (Response tokens)
  • analytics.payload (A4T payload)
  • clickmetric.analytics.payload (Click tracking A4T payload)
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Syntax
1
public static void retrieveLocationContent(final List<TargetRequest> targetRequestList, final TargetParameters parameters)
Copied!
  • targetRequestList is a list of TargetRequest objects for various mbox locations.
  • parameters is the configured TargetParameters for the retrieve location request.
Example
1
// define parameters for first request
2
Map<String, String> mboxParameters1 = new HashMap<>();
3
mboxParameters1.put("status", "platinum");
4
5
TargetParameters parameters1 = new TargetParameters.Builder().parameters(mboxParameters1).build