Setup Adobe Experience Platform Mobile SDK

In this section, we provide information to help you set up the SDK.

Configure the Experience Platform extension

Before you can use the SDK, you must first set it up.

Set up the required configuration

In your application's assets folder, configure a bundle configuration called ADBMobileConfig.json with the following content:

{
"global.privacy": "optedin",
"experienceCloud.org": "[email protected]",
"experiencePlatform.configId": "CONFIG_ID"
}

Replace the COMPANY_ORG_ID with your company's Adobe organization ID and CONFIG_ID with the Experience Platform configuration identifier for your schema and dataset.

Register the extension

The registerExtension() API registers the Experience Platform extension with the Mobile Core extension. This API allows the extension to send and receive events to and from the Experience Platform Mobile SDK.

Android
iOS
Android

In the Application file's onCreate() method, register the Mobile Core and the Experience Platform extensions.

public class ExperiencePlatformDemoApplication extends Application {
...
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
try {
// register Mobile Core extensions
Identity.registerExtension();
Signal.registerExtension();
Lifecycle.registerExtension();
// register the Experience Platform extension
ExperiencePlatform.registerExtension();
} catch (InvalidInitException e) {
e.printStackTrace();
}
MobileCore.start(new AdobeCallback() {
@Override
public void call(final Object o) {
Log.d(LOG_TAG, "Mobile SDK was initialized.");
}
});
}
...
}
iOS
import UIKit
import ACPExperiencePlatform
import ACPCore
import ACPGriffon
import xdmlib
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
ACPIdentity.registerExtension()
ACPLifecycle.registerExtension()
ACPExperiencePlatform.registerExtension()
let filePath = Bundle.main.path(forResource: "ADBMobileConfig", ofType: "json")
ACPCore.configureWithFile(inPath: filePath)
ACPCore.start({
ACPCore.lifecycleStart(nil)
})
return true
}
}

Sending events

After you create an Experience Platform event, use sendEvent to send this event to the Adobe solutions for which you are provisioned and to the Experience Platform. For more information, see Experience Platform event.

Android
iOS
Android

Syntax

public static void sendEvent(final ExperiencePlatformEvent experiencePlatformEvent, final ExperiencePlatformCallback responseCallback)
  • experiencePlatformEvent (required) event to be sent to Adobe Data Platform. It should not be null.

  • responseCallback (optional) callback to be invoked when the response handles are received from Adobe Data Platform. It can be called on a different thread and may be invoked multiple times.

Example (commerce event)

// Create the ExperiencePlatformEvent for your use case
final String eventType = "commerce.productListAdds";
MobileSDKPlatformEventSchema xdmData = new MobileSDKPlatformEventSchema();
xdmData.setEventType(eventType);
xdmData.setCommerce(commerce);
xdmData.setProductListItems(itemsList);
ExperiencePlatformEvent event = new ExperiencePlatformEvent.Builder()
.setXdmSchema(xdmData)
.build();
// Send the event to the Experience Platform extension
ExperiencePlatform.sendEvent(event, null);
iOS

Syntax

public static func sendEvent(experiencePlatformEvent: ExperiencePlatformEvent, responseHandler: ExperiencePlatformResponseHandler? = nil)
  • experiencePlatformEvent (required) event to be sent to Adobe Data Platform. It should not be null.

  • responseHandler (optional) callback to be invoked when the response handles are received from Adobe Data Platform. It can be called on a different thread and may be invoked multiple times.

Example (commerce event)

// Create the ExperiencePlatformEvent for your use case
var productItem = ProductListItemsItem()
productItem.name = "red ball"
productItem.SKU = "625-740"
productItem.currencyCode = "USD"
productItem.quantity = 1
productItem.priceTotal = 9.95
var itemsList: [ProductListItemsItem]
itemsList.append(productItem)
var commerce = Commerce()
var productViews = ProductViews()
productViews.value = 1
commerce.productViews = productViews
var xdmData = MobileSDKPlatformEventSchema()
xdmData.eventType = "commerce.productListAdds"
xdmData.commerce = commerce
xdmData.productListItems = itemsList
// Send the event to the Experience Platform extension
let event = ExperiencePlatformEvent(xdm:xdmData)
let responseHandler = ResponseHandler()
ACPExperiencePlatform.sendEvent(experiencePlatformEvent: event, responseHandler: responseHandler)

Retrieving data from Adobe solutions

As described in the Sending events section, the server-side event handle comes in chunks for the best performance. However, to be notified when a response is returned from the Adobe solutions, you can register a responseCallback(Android) /responseHandler (iOS) that is invoked when new data is available from the server. This callback is invoked for each event handle that is returned by the server and so it can be called multiple times.

Tip: In Android, the event handle is represented by a Map<String, Object>.

Depending on the nature of the event, and the various Adobe solutions you enabled for your organization, you can receive one, multiple, or no event handles for each Experience Platform event.

Android
iOS
Android
// Create the ExperiencePlatformEvent for your use case
...
// Send the event to the Experience Platform extension
ExperiencePlatform.sendEvent(event, new ExperiencePlatformCallback() {
@Override
public void onResponse(final Map<String, Object> data) {
// TODO: handle the data received from the server
Log.d(LOG_TAG, String.format("Received Data Platform response for event '%s': %s", eventType, data));
}
});
iOS
// Create the ExperiencePlatformEvent for your use case
...
// Send the event to the Experience Platform extension
ACPExperiencePlatform.sendEvent(experiencePlatformEvent: event, responseHandler: ResponseHandler())
// Handle the response from Experience Platform
class ResponseHandler : ExperiencePlatformResponseHandler {
func onResponse(data: [String : Any]) {
ACPCore.log(ACPMobileLogLevel.debug, tag:"ResponseHandler", message:"Platform response has been received...")
}
}

For more information about about response and error response handling, see Server response handling.