Edit in GitHubLog an issue

Java

  1. Add the Mobile Core and Target extensions to your project using the app's Gradle file.
Copied to your clipboard
implementation 'com.adobe.marketing.mobile:sdk-core:1.+'
implementation 'com.adobe.marketing.mobile:target:1.+'
  1. Add the ACPCore and ACPTarget CocoaPods to your project via your Podfile.
Copied to your clipboard
pod 'ACPCore','~>2.0'
pod 'ACPTarget','~>2.0'

JavaScript

  1. Install Target.
Copied to your clipboard
npm install @adobe/react-native-acptarget
react-native link @adobe/react-native-acptarget
  1. Import the extension and related libraries.
Copied to your clipboard
import {ACPTarget, ACPTargetPrefetchObject, ACPTargetRequestObject, ACPTargetOrder, ACPTargetProduct, ACPTargetParameters} from '@adobe/react-native-acptarget';
  1. Get the extension version.
Copied to your clipboard
ACPTarget.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPTarget version: " + version));

Java

In your Application's onCreate() method, after calling the setApplication() method, register Target with Mobile Core.

Here is code sample that calls these set up methods:

Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Target;
import com.adobe.marketing.mobile.Identity;
public class TargetApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
MobileCore.configureWithAppId("yourAppId");
try {
Target.registerExtension();
Identity.registerExtension();
MobileCore.start(null);
} catch (Exception e) {
//Log the exception
}
}
}

Swift

Copied to your clipboard
import ACPCore
import ACPTarget
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ACPCore.configure(withAppId: "yourAppId")
ACPTarget.registerExtension()
ACPIdentity.registerExtension()
ACPCore.start(nil)
// Override point for customization after application launch.
return true
}

Objective-C

In your app's didFinishLaunchingWithOptions function, register the Target extension with Mobile Core:

Copied to your clipboard
#import "ACPCore.h"
#import "ACPTarget.h"
#import "ACPIdentity.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[ACPCore configureWithAppId:@"yourAppId"];
[ACPTarget registerExtension];
[ACPIdentity registerExtension];
[ACPCore start:nil];
// Override point for customization after application launch.
return YES;
}

To register the Target extension with the Mobile Core extension, use the following API:

JavaScript

Copied to your clipboard
ACPTarget.registerExtension();

Java

Syntax

Copied to your clipboard
public TargetOrder(final String id, final double total, final List<String> purchasedProductIds)

Example

Copied to your clipboard
List<String> purchasedProductIds = new ArrayList<String>();
purchasedProductIds.add("34");
purchasedProductIds.add("125");
TargetOrder targetOrder = new TargetOrder("123", 567.89, purchasedProductIds);

Swift

Syntax

Copied to your clipboard
public convenience init(id orderId: String, total: NSNumber?, purchasedProductIds: [String]?)

Example

Copied to your clipboard
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])

Objective-C

Syntax

Copied to your clipboard
+ (nonnull instancetype) targetOrderWithId: (nonnull NSString*) orderId total: (nullable NSNumber*) total purchasedProductIds: (nullable NSArray <NSString*>*) purchasedProductIds;

Example

Copied to your clipboard
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];

JavaScript

Copied to your clipboard
var targetOrder = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);

Java

Syntax

Copied to your clipboard
public TargetProduct(final String id, final String categoryId)

Example

Copied to your clipboard
TargetProduct targetProduct = new TargetProduct("123", "Books");

Swift

Syntax

Copied to your clipboard
public convenience init(id productId: String, categoryId: String?)

Example

Copied to your clipboard
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")

Objective-C

Syntax

Copied to your clipboard
+ (nonnull instancetype) targetProductWithId: (nonnull NSString*) productId categoryId: (nullable NSString*) categoryId;

Example

Copied to your clipboard
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];

JavaScript

Copied to your clipboard
var targetProduct = new ACPTargetProduct("24D334", "Stationary");

Java

Syntax

Copied to your clipboard
TargetParameters targetParameters = new TargetParameters.Builder()
.parameters(new HashMap<String, String>())
.profileParameters(new HashMap<String, String>())
.product(new TargetProduct("productId", "productCategoryId"))
.order(new TargetOrder("orderId", 0.0, new ArrayList<String>()))
.build();

Example

Copied to your clipboard
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");
Map<String, String> mboxParameters = new HashMap<String, String>();
mboxParameters1.put("status", "platinum");
Map<String, String> profileParameters = new HashMap<String, String>();
profileParameters1.put("gender", "male");
TargetParameters targetParameters = new TargetParameters.Builder()
.parameters(mboxParameters)
.profileParameters(profileParameters)
.product(targetProduct)
.order(targetOrder)
.build();

Swift

Syntax

Copied to your clipboard
public convenience init(parameters: [AnyHashable: Any]?, profileParameters: [AnyHashable: Any]?, order: ACPTargetOrder?, product: ACPTargetProduct?)

Example

Copied to your clipboard
let mboxParameters = [
"status": "Platinum"
]
let profileParameters = [
"gender": "female"
]
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)

Objective-C

Syntax

Copied to your clipboard
+ (nonnull instancetype) targetParametersWithParameters: (nullable NSDictionary*) targetParameters profileParameters: (nullable NSDictionary*) profileParameters product: (nullable ACPTargetProduct*) product order: (nullable ACPTargetOrder*) order;

Example

Copied to your clipboard
NSDictionary *mboxParameters = @{@"status":@"Platinum"};
NSDictionary *profileParameters = @{@"gender":@"female"};
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];

JavaScript

Copied to your clipboard
var mboxParameters = {"status": "platinum"};
var profileParameters = {"gender": "female"};
var targetProduct = new ACPTargetProduct("24D334", "Stationary");
var purchaseIDs = ["34","125"];
var targetOrder = new ACPTargetOrder("ADCKKBC", 400.50, purchaseIDs);
var targetParameters = new ACPTargetParameters(mboxParameters, profileParameters, targetProduct, targetOrder);

On Android, when the application is launched as a result of a deep link, the Mobile Core's collectLaunchInfo API is internally invoked, and the Target activity and deep link information is extracted from the Intent extras.

The SDK can only collect information from the launching Activity if setApplication API has been called. Setting the Application is only necessary on an Activity that is also an entry point for your application. However, setting the Application on each Activity has no negative impact and ensures that the SDK always has the necessary reference to your Application. We recommend that you call setApplication API in each of your Activities.

On iOS, the Mobile Core's collectLaunchInfo API can be invoked with the Target preview deep link as shown below:

Swift

Example

Copied to your clipboard
ACPCore.collectLaunchInfo(["adb_deeplink" : "com.adobe.targetpreview://app.adobetarget.com?at_preview_token=tokenFromTarget"])

Objective-C

Example

Copied to your clipboard
[ACPCore collectLaunchInfo: @{@"adb_deeplink":@"com.adobe.targetpreview://app.adobetarget.com?at_preview_token=tokenFromTarget"}];`
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.