Target API reference

Get custom visitor IDs

Use this API to get the custom visitor ID for Target.

Android
iOS
React Native

getThirdPartyId

The callback is invoked to return the thirdPartyId value, or if no third-party ID is set, null is returned

Syntax

public static void getThirdPartyId(final AdobeCallback<String> callback)

Example

Target.getThirdPartyId(new AdobeCallback<String>() {
@Override
public void call(String thirdPartyID) {
// read Target thirdPartyID
}
});

getThirdPartyId

The callback is invoked to return the thirdPartyId value, or if no third-party ID is set, null is returned.

Syntax

+ (void) getThirdPartyId: (nonnull void (^) (NSString* __nullable thirdPartyId)) callback;

Examples

Here are the examples in Objective C and Swift:

Objective C

[ACPTarget getThirdPartyId:^(NSString *thirdPartyId){
// read Target thirdPartyId
}];

Swift

ACPTarget.getThirdPartyId({thirdPartyID in
// read Target thirdPartyId
})

getThirdPartyId

The callback is invoked to return the thirdPartyId value, or if no third-party ID is set, null is returned.

JavaScript

ACPTarget.getThirdPartyId().then(thirdPartyId =>
// read Target thirdPartyId
));

Set custom visitor IDs

Use this API to set custom visitor IDs for Target.

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 reset experience API is used.

Android
iOS
React Native

setThirdPartyId

Syntax

public static void setThirdPartyId(final String thirdPartyId)

Example

Target.setThirdPartyId("third-party-id");

setThirdPartyId

This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall or when resetExperience API is called.

Syntax

+ (void) setThirdPartyId: (nullable NSString*) thirdPartyId;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

[ACPTarget setThirdPartyId:@"third-party-id"];

Swift

ACPTarget.setThirdPartyId("third-party-id")

setThirdPartyId

JavaScript

ACPTarget.setThirdPartyId("third-party-id");

Get Target user identifier

Use this API to get the Target user identifier.

Android
iOS
React Native

getTntId

The callback is invoked to return the tntId value, or if no Target ID is set, null is returned.

With a successful call to loadRequests or prefetchContent, Target returns the tntId. Once set 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 resetExperience API is called.

Syntax

public static void getTntId(final AdobeCallback<String> callback)

Example

Target.getTntId(new AdobeCallback<String>() {
@Override
public void call(String value) {
// read target's tntid
}
});

getTntId

The callback is invoked to return the tntId value, or if no Target ID is set, nil is returned.

With a successful call to loadRequests or prefetchContent, Target returns the tntId. Once set 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 resetExperience API is called.

Syntax

+ (void) getTntId: (nonnull void (^) (NSString* __nullable tntId)) callback;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

[ACPTarget getTntId:^(NSString *tntId){
// read target's tntId
}];

Swift

ACPTarget.getTntId({tntId in
// read target's tntId
})

getTntId

The callback is invoked to return the tntId value, or if no Target ID is set, null is returned.

With a successful call to loadRequests or prefetchContent, Target returns the tntId. Once set 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 resetExperience API is called.

JavaScript

ACPTarget.getTntId().then(tntId =>
// read target's tntId
));

Reset user experience

Use this API to reset the user's experience by removing the visitor identifiers and resetting Target session. This method also removes previously set Target user ID and custom visitor IDs, Target Edge Host and session information from persistent storage.

Android
iOS
React Native

resetExperience

Syntax

public static void resetExperience()

Example

Target.resetExperience();

resetExperience

Syntax

+ (void) resetExperience;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

[ACPTarget resetExperience];

Swift

ACPTarget.resetExperience()

resetExperience

JavaScript

ACPTarget.resetExperience();

Set preview restart deeplink

Use this API to set the Target preview URL to be displayed when the preview mode is enabled and preview selections are confirmed.

Android
iOS
React Native

Syntax

public static void setPreviewRestartDeepLink(final Uri deepLink)

Example

Target.setPreviewRestartDeepLink("myapp://HomePage");

Syntax

+ (void) setPreviewRestartDeeplink: (nonnull NSURL*) deeplink;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

[ACPTarget setPreviewRestartDeepLink:@"myapp://HomePage"];

Swift

ACPTarget.setPreviewRestartDeepLink("myapp://HomePage")

JavaScript

ACPTarget.setPreviewRestartDeeplink("myapp://HomePage");

Prefetch offers

The SDK can minimize the number of times it reaches out to Target servers to fetch offers by caching server responses. With a successful prefetch call for mbox locations, offer content is retrieved and cached in the SDK. This content is retrieved from the cache for all future retrieveLocationContent API calls for the specified mbox names. This prefetch process reduces offer load time, network calls made to Target servers, and allows Target to be notified which mbox was visited by the mobile app user.

Prefetched offer content does not persist across application launches. The prefetch content is cached as long as the application lives in memory or until the API to clear the cache is called. For more information, see Clear prefetch offer cache.

Android
iOS
React Native

TargetPrefetch constructor

Using the TargetPrefetch constructor, you can create a TargetPrefetch instance with the specified data. It accepts the mbox location name and an optional TargetParameters object. The returned instance can be used with prefetchContent API to prefetch offers for the specified mbox locations.

Syntax

public TargetPrefetch(final String mboxName, final TargetParameters targetParameters)

Example

TargetParameters targetParameters = new TargetParameters.Builder()
.product(new TargetProduct(String, String))
.order(new TargetOrder(String, Double, List<String>))
.parameters(mboxParameters)
.profileParameters(profileParameters).build();
TargetPrefetch prefetchRequest = new TargetPrefetch("mboxName", targetParameters);

prefetchContent

Use this API to send a prefetch request to your configured Target server with the TargetPrefetch list and the specified TargetParameters. The callback is invoked when the prefetch is complete and, if successful, returns a null value. If the prefetch is not successful, an error message is returned.

Syntax

public static void prefetchContent(final List<TargetPrefetch> targetPrefetchList,
final TargetParameters targetParameters,
final final AdobeCallback<String> callback);

Example

// first prefetch request
Map<String, Object> mboxParameters1 = new HashMap<>();
mboxParameters1.put("status", "platinum");
// second prefetch request
Map<String, Object> mboxParameters2 = new HashMap<>();
mboxParameters2.put("userType", "paid");
List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("34");
purchasedIds.add("125");
TargetOrder targetOrder = new TargetOrder("ADCKKIM", 344.30, purchasedIds);
TargetProduct targetProduct = new TargetProduct("24D3412", "Books");
TargetParameters targetParameters1 = new TargetParameters.Builder()
.parameters(mboxParameters1)
.build();
TargetPrefetch prefetchRequest1 = new TargetPrefetch("mboxName1", targetParameters1);
TargetParameters targetParameters2 = new TargetParameters.Builder()
.parameters(mboxParameters2)
.product(targetProduct)
.order(targetOrder)
.build();
TargetPrefetch prefetchRequest2 = new TargetPrefetch("mboxName2", targetParameters2);
List<TargetPrefetchObject> prefetchMboxesList = new ArrayList<>();
prefetchMboxesList.add(prefetchRequest1);
prefetchMboxesList.add(prefetchRequest2);
// Call the prefetchContent API.
TargetParamters targetParameters = null;
Target.prefetchContent(prefetchMboxesList, targetParameters, prefetchStatusCallback);

prefetchContent

Use this API to send a prefetch request to your configured Target server with the ACPTargetPrefetchObject array and the specified ACPTargetParameters. The callback is invoked when the prefetch is complete and, if successful, returns a nil value. If the prefetch is not successful, an error message is returned.

Syntax

+ (void) prefetchContent: (nonnull NSArray<ACPTargetPrefetchObject*>*) targetPrefetchObjectArray
withParameters: (nullable ACPTargetParameters*) targetParameters
callback: (nullable void (^) (NSError* _Nullable error)) callback;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

NSDictionary *mboxParameters1 = @{@"status":@"platinum"};
NSDictionary *profileParameters1 = @{@"age":@"20"};
ACPTargetProduct *product1 = [ACPTargetProduct targetProductWithId:@"24D3412" categoryId:@"Books"];
ACPTargetOrder *order1 = [ACPTargetOrder targetOrderWithId:@"ADCKKIM" total:@(344.30) purchasedProductIds:@[@"34", @"125"]];
ACPTargetParameters *targetParameters1 = [ACPTargetParameters targetParametersWithParameters:mboxParameters1
profileParameters:profileParameters1
product:product1
order:order1];
NSDictionary *mboxParameters2 = @{@"userType":@"Paid"};
ACPTargetProduct *product2 = [ACPTargetProduct targetProductWithId:@"764334" categoryId:@"Online"];
ACPTargetOrder *order2 = [ACPTargetOrder targetOrderWithId:@"ADCKKIM" total:@(344.30) purchasedProductIds:@[@"id1",@"id2"]];
ACPTargetParameters *targetParameters2 = [ACPTargetParameters targetParametersWithParameters:mboxParameters2
profileParameters:nil
product:product2
order:order2];
// Creating Prefetch Objects
ACPTargetPrefetchObject *prefetch1 = [ACPTargetPrefetchObject targetPrefetchObjectWithName:@"logo"
targetParameters:targetParameters1];
ACPTargetPrefetchObject *prefetch2 = [ACPTargetPrefetchObject targetPrefetchObjectWithName:@"buttonColor"
targetParameters:targetParameters2];
// Creating prefetch Array
NSArray *prefetchArray = @[prefetch1,prefetch2];
// Creating Target parameters
NSDictionary *mboxParameters = @{@"status":@"progressive"};
NSDictionary *profileParameters = @{@"age":@"20-32"};
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:mboxParameters
profileParameters:profileParameters
product:product
order:order];
// Target API Call
[ACPTarget prefetchContent:prefetchArray withParameters:targetParameters callback:^(NSError * _Nullable error){
// do something with the callback response
}];

Swift

let mboxParameters1 = [
"status": "platinum"
]
let profileParameters1 = [
"age": "20"
]
let product1 = ACPTargetProduct(id: "24D3412", categoryId: "Books")
let order1 = ACPTargetOrder(id: "ADCKKIM", total: NSNumber(value: 344.30), purchasedProductIds: ["34", "125"])
let targetParameters1 = ACPTargetParameters(parameters: mboxParameters1, profileParameters: profileParameters1, product: product1, order: order1)
let mboxParameters2 = [
"userType": "Paid"
]
let product2 = ACPTargetProduct(id: "764334", categoryId: "Online")
let order2 = ACPTargetOrder(id: "ADCKKIM", total: NSNumber(value: 344.30), purchasedProductIds: ["id1", "id2"])
let targetParameters2 = ACPTargetParameters(parameters: mboxParameters2, profileParameters: nil, product: product2, order: order2)
// Creating Prefetch Objects
let prefetch1 = ACPTargetPrefetchObject(name: "logo", targetParameters: targetParameters1)
let prefetch2 = ACPTargetPrefetchObject(name: "buttonColor", targetParameters: targetParameters2)
// Creating prefetch Array
let prefetchArray = [prefetch1, prefetch2]
// Creating Target parameters
let mboxParameters = [
"status": "progressive"
]
let profileParameters = [
"age": "20-32"
]
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
let targetParameters = ACPTargetParameters(parameters: mboxParameters, profileParameters: profileParameters, product: product, order: order)
// Target API Call
ACPTarget.prefetchContent(prefetchArray, with: targetParameters, callback: { error in
// do something with the callback response
})

prefetchContent

Use this API to send a prefetch request to your configured Target server with the ACPTargetPrefetchObject array and the specified ACPTargetParameters. The callback is invoked when the prefetch is complete and, if successful, returns a null value. If the prefetch is not successful, an error message is returned.

JavaScript

var mboxParameters1 = {"status": "platinum"};
var profileParameters1 = {"age": "20"};
var product1 = new ACPTargetProduct("24D3412", "Books");
var order1 = new ACPTargetOrder("ADCKKIM", 344.30, ["34","125"]);
var targetParameters1 = new ACPTargetParameters(mboxParameters1, profileParameters1, product1, order1);
var mboxParameters2 = {"userType": "Paid"};
var product2 = new ACPTargetProduct("764334", "Online");
var order2 = new ACPTargetOrder("ADCKKIM", 344.30, ["id1","id2"]);
var targetParameters2 = new ACPTargetParameters(mboxParameters2, null, product2, order2);
// Creating Prefetch Objects
var prefetch1 = new ACPTargetPrefetchObject("logo", targetParameters1);
var prefetch2 = new ACPTargetPrefetchObject("buttonColor", targetParameters2);
// Creating prefetch Array
var prefetchList = [prefetch1, prefetch2];
// Creating Target parameters
var mboxParameters = {"status": "progressive"};
var profileParameters = {"age": "20-32"};
var product = new ACPTargetProduct("24D334", "Stationary");
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);
var targetParameters = new ACPTargetParameters(mboxParameters, profileParameters, product, order);
// Target API Call
ACPTarget.prefetchContent(prefetchList, targetParameters).then(success => console.log(success)).catch(err => console.log(err));

Clear prefetch offer cache

Use this API to clear prefetched offers cached in memory.

Android
iOS
React Native

clearPrefetchCache

Syntax

public static void clearPrefetchCache()

Example

Target.clearPrefetchCache();

clearPrefetchCache

Syntax

+ (void) clearPrefetchCache;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

[ACPTarget clearPrefetchCache];

Swift

ACPTarget.clearPrefetchCache()

clearPrefetchCache

JavaScript

ACPTarget.clearPrefetchCache();

Retrieve Location Content requests

Use this API to send a batch request to the configured Target server for multiple mbox locations. The main difference with the deprecated loadRequests API is in usage with prefetch APIs. For a prefetched mbox, unlike loadRequests API, invoking this API does not send a display notification to the configured Target server. If you are not prefetching mbox content, then there is no difference with loadRequests API for sending batch request to Target.

Android
iOS
React Native

retrieveLocationContent

For mbox locations in the TargetRequest list that are not already prefetched, this API sends a batch request to the configured Target server. 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 TargetRequest object in the list contains a callback function, which is invoked when content is available for its given mbox location.

Syntax

public static void retrieveLocationContent(final List<TargetRequest> targetRequestList,
final TargetParameters parameters)

Example

// define parameters for first request
Map<String, Object> mboxParameters1 = new HashMap<>();
mboxParameters1.put("status", "platinum");
// define parameters for second request
Map<String, Object> mboxParameters2 = new HashMap<>();
mboxParameters2.put("userType", "paid");
List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("34");
purchasedIds.add("125");
TargetOrder targetOrder = new TargetOrder("ADCKKIM", 344.30, purchasedIds);
TargetProduct targetProduct = new TargetProduct("24D3412", "Books");
TargetParameters parameters1 = new TargetParameters.Builder().parameters(mboxParameters1).build();
TargetRequest request1 = new TargetRequest("mboxName1", parameters1, "defaultContent1",
new AdobeCallback<String>() {
@Override
public void call(String value) {
// do something with target content.
}
});
TargetParameters parameters2 = new TargetParameters.Builder()
.parameters(mboxParameters1)
.product(targetProduct)
.order(targetOrder)
.build();
TargetRequest request2 = new TargetRequest("mboxName2", parameters2, "defaultContent2",
new AdobeCallback<String>() {
@Override
public void call(String value) {
// do something with target content.
}
});
// Creating Array of Request Objects
List<TargetRequest> locationRequests = new ArrayList<>();
locationRequests.add(request1);
locationRequests.add(request2);
// Define the profile parameters map.
Map<String, Object> profileParameters1 = new HashMap<>();
profileParameters1.put("ageGroup", "20-32");
TargetParameters parameters = new TargetParameters.Builder().profileParameters(profileParameters1).build();
// Call the targetRetrieveLocationContent API.
Target.retrieveLocationContent(locationRequests, parameters);

retrieveLocationContent

For mbox locations in the TargetRequest list that are not already prefetched, this API sends a batch request to the configured Target server. 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 TargetRequest object in the list contains a callback function, which is invoked when content is available for its given mbox location.

Syntax

+ (void) retrieveLocationContent: (nonnull NSArray<ACPTargetRequestObject*>*) requests
withParameters: (nullable ACPTargetParameters*) parameters;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

NSDictionary *mboxParameters1 = @{@"status":@"platinum"};
ACPTargetProduct *product1 = [ACPTargetProduct targetProductWithId:@"24D3412" categoryId:@"Books"];
ACPTargetOrder *order1 = [ACPTargetOrder targetOrderWithId:@"ADCKKIM" total:@(344.30) purchasedProductIds:@[@"a", @"b"]];
NSDictionary *mboxParameters2 = @{@"userType":@"Paid"};
ACPTargetProduct *product2 = [ACPTargetProduct targetProductWithId:@"764334" categoryId:@"Online"];
ACPTargetOrder *order2 = [ACPTargetOrder targetOrderWithId:@"4t4uxksa" total:@(54.90) purchasedProductIds:@[@"id1",@"id2"]];
ACPTargetParameters *params1 = [ACPTargetParameters targetParametersWithParameters:mboxParameters1
profileParameters:nil
product:product1
order:order1];
ACPTargetRequestObject *request1 = [ACPTargetRequestObject targetRequestObjectWithName:@"logo" targetParameters:params1
defaultContent:@"BlueWhale" callback:^(NSString * _Nullable content) {
// do something with the received content
}];
ACPTargetParameters *params2 = [ACPTargetParameters targetParametersWithParameters:mboxParameters2
profileParameters:nil
product:product2
order:order2];
ACPTargetRequestObject *request2 = [ACPTargetRequestObject targetRequestObjectWithName:@"logo" targetParameters:params2
defaultContent:@"red" callback:^(NSString * _Nullable content) {
// do something with the received content
}];
// Create request object array
NSArray *requestArray = @[request1,request2];
// Creating Target parameters
NSDictionary *mboxParameters = @{@"status":@"progressive"};
NSDictionary *profileParameters = @{@"age":@"20-32"};
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:mboxParameters
profileParameters:profileParameters
product:product
order:order];
// Call the API
[ACPTarget retrieveLocationContent:requestArray withParameters:targetParameters];

Swift

let mboxParameters1 = [
"status": "platinum"
]
let product1 = ACPTargetProduct(id: "24D3412", categoryId: "Books")
let order1 = ACPTargetOrder(id: "ADCKKIM", total: NSNumber(value: 344.30), purchasedProductIds: ["a", "b"])
let mboxParameters2 = [
"userType": "Paid"
]
let product2 = ACPTargetProduct(id: "764334", categoryId: "Online")
let order2 = ACPTargetOrder(id: "4t4uxksa", total: NSNumber(value: 54.90), purchasedProductIds: ["id1", "id2"])
let params1 = ACPTargetParameters(parameters: mboxParameters1, profileParameters: nil, product: product1, order: order1)
let request1 = ACPTargetRequestObject(name: "logo", targetParameters: params1, defaultContent: "BlueWhale", callback: { content in
// do something with the received content
})
let params2 = ACPTargetParameters(parameters: mboxParameters2, profileParameters: nil, product: product2, order: order2)
let request2 = ACPTargetRequestObject(name: "logo", targetParameters: params2, defaultContent: "red", callback: { content in
// do something with the received content
})
// Create request object array
let requestArray = [request1, request2]
// Creating Target parameters
let mboxParameters = [
"status": "progressive"
]
let profileParameters = [
"age": "20-32"
]
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
let targetParameters = ACPTargetParameters(parameters: mboxParameters, profileParameters: profileParameters, product: product, order: order)
// Call the API
ACPTarget.retrieveLocationContent(requestArray, with: targetParameters)

retrieveLocationContent

For mbox locations in the TargetRequest list that are not already prefetched, this API sends a batch request to the configured Target server. 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 TargetRequest object in the list contains a callback function, which is invoked when content is available for its given mbox location.

JavaScript

var mboxParameters1 = {"status": "platinum"};
var product1 = new ACPTargetProduct("24D3412", "Books");
var order1 = new ACPTargetOrder("ADCKKIM", 344.30, ["a","b"]);
var mboxParameters2 = {"userType": "Paid"};
var product2 = new ACPTargetProduct("764334", "Online");
var order2 = new ACPTargetOrder("4t4uxksa", 54.90, ["id1","id2"]);
var params1 = new ACPTargetParameters(mboxParameters1, null, product1, order1);
var request1 = new ACPTargetRequestObject("logo", params1, "BlueWhale", (error, content) => {
if (error) {
console.error(error);
} else {
console.log("Target content:" + content);
}
});
var params2 = new ACPTargetParameters(mboxParameters2, null, product2, order2);
var request2 = new ACPTargetRequestObject("logo", params1, "red", (error, content) => {
if (error) {
console.error(error);
} else {
console.log("Target content:" + content);
}
});
// Create request object array
let requestArray = [request1, request2]
// Creating Target parameters
var mboxParameters = {"status": "progressive"};
var profileParameters = {"age": "20-32"};
var product = new ACPTargetProduct("24D334", "Stationary");
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);
var targetParameters = new ACPTargetParameters(mboxParameters, profileParameters, product, order);
// Target API Call
ACPTarget.retrieveLocationContent(requestArray, targetParameters);

Send an mbox display notification

Use this API to send a location (mbox) display notification to configured Target server. This API should be invoked for a prefetched mbox, after the mbox content is retrieved using retrieveLocationContent API. If no previous prefetch request is made and the mbox content is retrieved using retrieveLocationContent API, then calling this API does not trigger a notification request to the Target server.

Do not use this API with the deprecated loadRequests. For a prefetched mbox, on calling the deprecated loadRequests API, mbox display notification is internally sent to the Target server by the SDK.

Android
iOS
React Native

locationsDisplayed

Syntax

public static void locationsDisplayed(final List<String> mboxNames, final TargetParameters targetParameters)

Example

List<String> purchasedProductIds = new ArrayList<String>();
purchasedProductIds.add("34");
purchasedProductIds.add("125");
TargetOrder targetOrder = new TargetOrder("123", 567.89, purchasedProductIds);
TargetProduct targetProduct = new TargetProduct("123", "Books");
TargetParameters targetParameters = new TargetParameters.Builder()
.parameters(new HashMap<String, String>())
.profileParameters(new HashMap<String, String>())
.product(targetProduct)
.order(targetOrder)
.build();
List<String> mboxList = new ArrayList<>();
mboxList.add("mboxName1");
Target.locationsDisplayed(mboxList, targetParameters);

locationsDisplayed

Syntax

+ (void) locationsDisplayed: (nonnull NSArray<NSString*>*) mboxNames
withTargetParameters: (nullable ACPTargetParameters*) targetParameters;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:nil
profileParameters:nil
product:product
order:order];
[ACPTarget locationsDisplayed:@[@"mboxName1", @"mboxName2"] withTargetParameters:targetParameters];

Swift

let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
let targetParameters = ACPTargetParameters(parameters: nil, profileParameters: nil, product: product, order: order)
ACPTarget.locationsDisplayed(["mboxName1", "mboxName2"], with: targetParameters)

locationsDisplayed

JavaScript

var product = new ACPTargetProduct("24D334", "Stationary");
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34", "125"]);
var targetParameters = new ACPTargetParameters(null, null, product, order);
ACPTarget.locationsDisplayed(["mboxName1", "mboxName2"], targetParameters);

Send an mbox click notification

Use this API to send a location (mbox) click notification to configured Target server. This API can be invoked in the following cases:

  • For a prefetched mbox, after the mbox content is retrieved using retrieveLocationContent API.

  • For a regular mbox when no previous prefetch request is made and the mbox content is retrieved using retrieveLocationContent API.

For a click notification to be sent to Target, make sure click metric is enabled for the given mbox name in Target.

Android
iOS
React Native

locationClicked

Syntax

public static void locationClicked(final String mboxName, final TargetParameters parameters)

Example

// Mbox parameters
Map<String, Object> mboxParameters = new HashMap<>();
mboxParameters.put("membership", "prime");
// Product parameters
Map<String, Object> productParameters = new HashMap<>();
productParameters.put("id", "CEDFJC");
productParameters.put("categoryId","Electronics");
List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("81");
purchasedIds.add("123");
purchasedIds.add("190");
// Order parameters
Map<String, Object> orderParameters = new HashMap<>();
orderParameters.put("id", "NJJICK");
orderParameters.put("total", "650");
orderParameters.put("purchasedProductIds", purchasedIds);
// Profile parameters
Map<String, Object> profileParameters = new HashMap<>();
profileParameters.put("ageGroup", "20-32");
// Create Target Parameters
TargetOrder targetOrder = new TargetOrder("NJJICK", "650", purchasedIds);
TargetProduct targetProduct = new TargetProduct("CEDFJC", "Electronics");
TargetParameters targetParameters = new TargetParameters.Builder(mboxParameters)
.profileParameters(profileParameters)
.order(targetOrder)
.product(targetProduct)
.build();
Target.locationClicked("cartLocation", targetParameters);

locationClicked

Syntax

+ (void) locationClickedWithName: (nonnull NSString*) name targetParameters: (nullable ACPTargetParameters*) parameters;

Examples

Here are some examples in Objective-C and Swift:

Objective-C

// Mbox parameters
NSDictionary *mboxParameters = @{@"membership":@"prime"};
// Product parameters
NSDictionary *productParameters = @{@"id":@"CEDFJC",
@"categoryId":@"Electronics"};
// Order parameters
NSDictionary *orderParameters = @{@"id":@"NJJICK",
@"total":@"650",
@"purchasedProductIds":@"81, 123, 190"};
// Profile parameters
NSDictionary *profileParameters = @{@"ageGroup":@"20-32"};
// Create Target parameters
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:nil
profileParameters:nil
product:product
order:order];
[ACPTarget locationClickedWithName:@"cartLocation" targetParameters:targetParameters];

Swift

// Mbox parameters
let mboxParameters = [
"membership": "prime"
]
// Product parameters
let productParameters = [
"id": "CEDFJC",
"categoryId": "Electronics"
]
// Order parameters
let orderParameters = [
"id": "NJJICK",
"total": "650",
"purchasedProductIds": "81, 123, 190"
]
// Profile parameters
let profileParameters = [
"ageGroup": "20-32"
]
// Create Target parameters
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
let targetParameters = ACPTargetParameters(parameters: nil, profileParameters: nil, product: product, order: order)
ACPTarget.locationClicked(withName: "cartLocation", targetParameters: targetParameters)

locationClicked

JavaScript

// Mbox parameters
var mboxParameters = {"membership": "prime"};
// Product parameters
var productParameters = new ACPTargetProduct("CEDFJC", "Electronics");
// Order parameters
var orderParameters = new ACPTargetOrder("NJJICK", 650, ["81","123","190"]);
// Profile parameters
var profileParameters = {"ageGroup": "20-32"};
// Create Target parameters
var product = new ACPTargetProduct("24D334", "Stationary");
var order = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);
var targetParameters = new ACPTargetParameters(null, null, product, order);
ACPTarget.locationClickedWithName("cartLocation", targetParameters);

Public classes

Android
iOS
React Native

TargetRequest

Here is a code sample for this class in Android:

public class TargetRequest extends TargetObject {
/**
* Instantiate a TargetRequest object
* @param mboxName String mbox name for this request
* @param targetParameters TargetParameters for this request
* @param defaultContent String default content for this request
* @param contentCallback AdobeCallback<String> which will get called with Target mbox content
*/
public TargetRequest(final String mboxName,
final TargetParameters targetParameters,
final String defaultContent,
final AdobeCallback<String> contentCallback);
/**
* Sets mbox parameters for the request.
*
* @param mboxParameters Map<String, String> mbox parameters
*/
void setMboxParameters(final Map<String, String> mboxParameters);
/**
* Sets profile parameters for the request.
*
* @param profileParameters Map<String, String profile parameters
*/
void setProfileParameters(final Map<String, String> profileParameters);
/**
* Sets order parameters for the request.
*
* @param orderParameters Map<String, Object> order parameters
*/
void setOrderParameters(final Map<String, Object> orderParameters);
/**
* Sets product parameters for the request.
*
* @param productParameters Map<String, String> product parameters
*/
void setProductParameters(final Map<String, String> productParameters);
/**
* Sets targetParameters for the request.
*
* @param targetParameters TargetParameters for the request.
*/
void setTargetParameters(final TargetParameters targetParameters);
}

TargetPrefetch

Here is a code sample for this class in Android:

public class TargetPrefetch extends TargetObject {
/**
* Instantiate a TargetPrefetch object
* @param mboxName String mbox name for this prefetch request
* @param targetParameters TargetParameters for this prefetch request
*/
public TargetPrefetch(final String mboxName, final TargetParameters targetParameters)
/**
* Sets mbox parameters for the request.
*
* @param mboxParameters Map<String, String> mbox parameters
*/
void setMboxParameters(final Map<String, String> mboxParameters);
/**
* Sets profile parameters for the request.
*
* @param profileParameters Map<String, String profile parameters
*/
void setProfileParameters(final Map<String, String> profileParameters);
/**
* Sets order parameters for the request.
*
* @param orderParameters Map<String, Object> order parameters
*/
void setOrderParameters(final Map<String, Object> orderParameters);
/**
* Sets product parameters for the request.
*
* @param productParameters Map<String, String> product parameters
*/
void setProductParameters(final Map<String, String> productParameters);
/**
* Sets targetParameters for the request.
*
* @param targetParameters TargetParameters for the request.
*/
void setTargetParameters(final TargetParameters targetParameters);
}

TargetParameters

Here is a code sample for this class in Android:

public class TargetParameters {
private TargetParameters() {}
/**
* Builder used to construct a TargetParameters object
*/
public static class Builder {
private Map<String, String> parameters;
private Map<String, String> profileParameters;
private TargetProduct product;
private TargetOrder order;
/**
* Create a TargetParameters object Builder
*/
public Builder() {}
/**
* Create a TargetParameters object Builder
*
* @param parameters mbox parameters for the built TargetParameters
*/
public Builder(final Map<String, String> parameters);
/**
* Set mbox parameters on the built TargetParameters
*
* @param parameters mbox parameters map
* @return this builder
*/
public Builder parameters(final Map<String, String> parameters);
/**
* Set profile parameters on the built TargetParameters
*
* @param profileParameters profile parameters map
* @return this builder
*/
public Builder profileParameters(final Map<String, String> profileParameters);
/**
* Set product parameters on the built TargetParameters
*
* @param product product parameters
* @return this builder
*/
public Builder product(final TargetProduct product);
/**
* Set order parameters on the built TargetParameters
*
* @param order order parameters
* @return this builder
*/
public Builder order(final TargetOrder order);
/**
* Build the TargetParameters object
*
* @return the built TargetParameters object
*/
public TargetParameters build();
}
}

TargetOrder

Here is a code sample for this class in Android:

public class TargetOrder {
/**
* Initialize a TargetOrder with an order id, order total and a list of purchasedProductIds
*
* @param id String order id
* @param total double order total amount
* @param purchasedProductIds a list of purchased product ids
*/
public TargetOrder(final String id, final double total, final List<String> purchasedProductIds);
/**
* Get the order id
*
* @return order id
*/
public String getId();
/**
* Get the order total
*
* @return order total
*/
public double getTotal();
/**
* Get the order purchasedProductIds
*
* @return a list of this order's purchased product ids
*/
public List<String> getPurchasedProductIds();
/**
* Converts an order parameter Map to a TargetOrder
*
* @param orderParameters a Map<String, Object> of Target order parameters
* @return converted TargetOrder
*/
static TargetOrder fromMap(final Map<String, Object> orderParameters);
/**
* Converts TargetOrder to an order parameters Map.
*
* @param targetOrder a TargetOrder object
* @return Map<String, Object> containing Target order parameters
*/
static Map<String, Object> toMap(final TargetOrder targetOrder);
}

TargetProduct

Here is a code sample for this class in Android:

public class TargetProduct {
/**
* Initialize a TargetProduct with a product id and a productCategoryId categoryId
*
* @param id String product id
* @param categoryId String product category id
*/
public TargetProduct(final String id, final String categoryId);
/**
* Get the product id
*
* @return product id
*/
public String getId();
/**
* Get the product categoryId
*
* @return product category id
*/
public String getCategoryId();
/**
* Converts a product parameter Map to a TargetProduct
*
* @param productParameters a Map<String, String> of Target product parameters
* @return converted TargetProduct
*/
static TargetProduct fromMap(final Map<String, String> productParameters);
/**
* Converts a TargetProduct object to product parameters Map.
*
* @param targetProduct a TargetProduct object
* @return Map<String, String> containing Target product parameters
*/
static Map<String, String> toMap(final TargetProduct targetProduct);
}