Mobile Core API reference
This document lists information about the previous versions of the Adobe Experience Platform Mobile SDKs. Check out this page for latest versions and solution support of the Mobile SDKs.
collectLaunchInfo
You can provide the user information to the SDK from various launch points in your application.
If the Adobe Analytics extension is enabled in your SDK, collecting this launch data results in an Analytics request being sent. Other extensions in the SDK might use the collected data, for example, as a rule condition for an In-App Message.
The Android SDK automatically registers an Application.ActivityLifecycleCallbacks
and listens for onActivityResumed
. When an activity is resumed, SDK collects the data from the activity. Currently, it is being used in the following scenarios:
- Tracking deep link clickthrough
- Tracking push message clickthrough
- Tracking Local Notification clickthrough
Swift
The collectLaunchInfo
method should be used in the following use cases:
- Tracking a deep link clickthrough
- From
application(_:didFinishLaunchingWithOptions:)
- Extract
userInfo
fromurl: UIApplication.LaunchOptionsKey
- From
- Tracking a push message clickthrough
- From
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
- From
Syntax
Copied to your clipboard(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Example
Copied to your clipboardACPCore.collectLaunchInfo(userInfo)
Objective-C
The collectLaunchInfo
method should be used in the following use cases:
- Tracking a deep link clickthrough
- From
application:didFinishLaunchingWithOptions
- Extract
userInfo
fromUIApplicationLaunchOptionsURLKey
- From
- Tracking a push message clickthrough
- From
application:didReceiveRemoteNotification:fetchCompletionHandler:
- From
Syntax
Copied to your clipboard(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Example
Copied to your clipboard[ACPCore collectLaunchInfo:launchOptions];
The Android SDK automatically registers an Application.ActivityLifecycleCallbacks
and listens for onActivityResumed
. When an activity is resumed, SDK collects the data from the activity. Currently, it is being used in the following scenarios:
- Tracking deep link clickthrough
- Tracking push message clickthrough
- Tracking Local Notification clickthrough
Swift
The collectLaunchInfo
method should be used in the following use cases:
- Tracking a deep link clickthrough
- From
application(_:didFinishLaunchingWithOptions:)
- Extract
userInfo
fromurl: UIApplication.LaunchOptionsKey
- From
- Tracking a push message clickthrough
- From
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
- From
Syntax
Copied to your clipboard(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Example
Copied to your clipboardACPCore.collectLaunchInfo(userInfo)
Objective-C
The collectLaunchInfo
method should be used in the following use cases:
- Tracking a deep link clickthrough
- From
application:didFinishLaunchingWithOptions
- Extract
userInfo
fromUIApplicationLaunchOptionsURLKey
- From
- Tracking a push message clickthrough
- From
application:didReceiveRemoteNotification:fetchCompletionHandler:
- From
Syntax
Copied to your clipboard(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Example
Copied to your clipboard[ACPCore collectLaunchInfo:launchOptions];
collectPii
The collectPii
method lets the SDK to collect sensitive or personally identifiable information (PII).
Although this method enables the collection of sensitive data, no data is sent to any Adobe or other third-party endpoints. To send the data to an endpoint, use a PII type postback.
Java
Syntax
Copied to your clipboardpublic static void collectPII(final Map<String, String> piiData);
Example
Copied to your clipboardMap<String, String> data = new HashMap<String, String>();data.put("firstname", "customer");//The rule to trigger a PII needs to be setup for this call//to result in a network sendMobileCore.collectPII(data);
Swift
Syntax
Copied to your clipboardACPCore.collectPii(data: [String : String])
Example
Copied to your clipboardMobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
Objective-C
Syntax
Copied to your clipboard(void) collectPii: (nonnull NSDictionary<NSString*, NSString*>*) data;
Example
Copied to your clipboard[ACPCore collectPii:data:@{@"key1" : "@value1",@"key2" : "@value2"}];
Javascript
Syntax
Copied to your clipboardACPCore.collectPii(data: [String : String])
Example
Copied to your clipboardACPCore.collectPii({"myPii": "data"});
Swift
Syntax
Copied to your clipboardACPCore.collectPii(data: [String : String])
Example
Copied to your clipboardMobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
Java
Syntax
Copied to your clipboardpublic static void collectPII(final Map<String, String> piiData);
Example
Copied to your clipboardMap<String, String> data = new HashMap<String, String>();data.put("firstname", "customer");//The rule to trigger a PII needs to be setup for this call//to result in a network sendMobileCore.collectPII(data);
Swift
Syntax
Copied to your clipboardACPCore.collectPii(data: [String : String])
Example
Copied to your clipboardMobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
Objective-C
Syntax
Copied to your clipboard(void) collectPii: (nonnull NSDictionary<NSString*, NSString*>*) data;
Example
Copied to your clipboard[ACPCore collectPii:data:@{@"key1" : "@value1",@"key2" : "@value2"}];
Javascript
Syntax
Copied to your clipboardACPCore.collectPii(data: [String : String])
Example
Copied to your clipboardACPCore.collectPii({"myPii": "data"});
Swift
Syntax
Copied to your clipboardACPCore.collectPii(data: [String : String])
Example
Copied to your clipboardMobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
getApplication
You can use the getApplication
method to get the previously set Android Application
instance. The Application
instance is mainly provided for third-party extensions.
Java
MobileCore.getApplication
will return null
if the Application
object was destroyed or if MobileCore.setApplication
was not previously called.
Syntax
Copied to your clipboardpublic static Application getApplication()
Example
Copied to your clipboardApplication app = MobileCore.getApplication();if (app != null) {...}
Java
MobileCore.getApplication
will return null
if the Application
object was destroyed or if MobileCore.setApplication
was not previously called.
Syntax
Copied to your clipboardpublic static Application getApplication()
Example
Copied to your clipboardApplication app = MobileCore.getApplication();if (app != null) {...}
getLogLevel
This API gets the current log level being used in the SDK.
Swift
Syntax
Copied to your clipboard(ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardlet logLevel:ACPMobileLogLevel = ACPCore.logLevel();
Objective-C
Syntax
Copied to your clipboard(ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardvar logLevel:ACPMobileLogLevel = [ACPCore logLevel];
Java
Syntax
Copied to your clipboardpublic static LoggingMode getLogLevel()
Example
Copied to your clipboardLoggingMode mode = MobileCore.getLogLevel();
Swift
Syntax
Copied to your clipboard(ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardlet logLevel:ACPMobileLogLevel = ACPCore.logLevel();
Objective-C
Syntax
Copied to your clipboard(ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardvar logLevel:ACPMobileLogLevel = [ACPCore logLevel];
getSdkIdentities
The following SDK identities are locally stored:
- Company Context - IMS Org IDs
- Experience Cloud ID (MID)
- User IDs
- Integration codes (ADID, push IDs)
- Data source IDs (DPID, DPUUID)
- Analytics IDs (AVID, AID, VID, and associated RSIDs)
- Target legacy IDs (TNTID, TNT3rdpartyID)
- Audience Manager ID (UUID)
To retrieve data as a JSON string from the SDKs and send this data to your servers, use the getSdkIdentities
method.
You must call the API below and retrieve identities stored in the SDK, before the user opts out.
This API does not include the identities stored in the Edge Identity extension. To retrieve the identities from the Edge Identity extension, use getIdentities.
Java
Syntax
Copied to your clipboardvoid getSdkIdentities(AdobeCallback<String> callback);
- callback is invoked with the SDK identities as a JSON string. If an instance of
AdobeCallbackWithError
is provided, and you are fetching the attributes from the Mobile SDK, the timeout value is 5000ms. If the operation times out or an unexpected error occurs, thefail
method is called with the appropriateAdobeError
.
Example
Copied to your clipboardMobileCore.getSdkIdentities(new AdobeCallback<String>() {@Overridepublic void call(String value) {// handle the json string}});
Objective-C
Syntax
Copied to your clipboard(void) getSdkIdentities: (nullable void (^) (NSString* __nullable content)) callback;(void) getSdkIdentitiesWithCompletionHandler: (nullable void (^) (NSString* __nullable content, NSError* _Nullable error)) completionHandler;
- callback is invoked with the SDK identities as a JSON string.
- completionHandler is invoked with the SDK identities as a JSON string, or error if an unexpected error occurs or the request times out. The default timeout is 1000ms.
Example
Copied to your clipboard[ACPCore getSdkIdentities:^(NSString * _Nullable content){NSLog(content);[ACPCore getSdkIdentitiesWithCompletionHandler:^(NSString * _Nullable content, NSError * _Nullable error) {if (error) {// handle error here} else {// handle the retrieved identitiesNSLog(content);}}];
Swift
Example
Copied to your clipboardMobileCore.getSdkIdentities { (content, error) in// handle completion}
Java
Syntax
Copied to your clipboardvoid getSdkIdentities(AdobeCallback<String> callback);
- callback is invoked with the SDK identities as a JSON string. If an instance of
AdobeCallbackWithError
is provided, and you are fetching the attributes from the Mobile SDK, the timeout value is 5000ms. If the operation times out or an unexpected error occurs, thefail
method is called with the appropriateAdobeError
.
Example
Copied to your clipboardMobileCore.getSdkIdentities(new AdobeCallback<String>() {@Overridepublic void call(String value) {// handle the json string}});
Objective-C
Syntax
Copied to your clipboard(void) getSdkIdentities: (nullable void (^) (NSString* __nullable content)) callback;(void) getSdkIdentitiesWithCompletionHandler: (nullable void (^) (NSString* __nullable content, NSError* _Nullable error)) completionHandler;
- callback is invoked with the SDK identities as a JSON string.
- completionHandler is invoked with the SDK identities as a JSON string, or error if an unexpected error occurs or the request times out. The default timeout is 1000ms.
Example
Copied to your clipboard[ACPCore getSdkIdentities:^(NSString * _Nullable content){NSLog(content);[ACPCore getSdkIdentitiesWithCompletionHandler:^(NSString * _Nullable content, NSError * _Nullable error) {if (error) {// handle error here} else {// handle the retrieved identitiesNSLog(content);}}];
Swift
Example
Copied to your clipboardMobileCore.getSdkIdentities { (content, error) in// handle completion}
log
This is the API used to log from the SDK.
Java
The MobileCore
logging APIs use the android.util.Log
APIs to log messages to Android. Based on the LoggingMode
that is passed to MobileCore.log()
, the following Android method is called:
LoggingMode.VERBOSE
usesandroid.util.Log.v
LoggingMode.DEBUG
usesandroid.util.Log.d
LoggingMode.WARNING
usesandroid.util.Log.w
LoggingMode.ERROR
usesandroid.util.Log.e
All log messages from the Adobe Experience SDK to Android use the same log tag of AdobeExperienceSDK
. For example, if logging an error message is using MobileCore.log()
, the call to android.util.Log.e
looks like Log.e("AdobeExperienceSDK", tag + " - " + message)
.
Syntax
Copied to your clipboardpublic static void log(final LoggingMode mode, final String tag, final String message)
Example
Copied to your clipboardMobileCore.log(LoggingMode.DEBUG, "MyClassName", "Provided data was null");
Output
Copied to your clipboardD/AdobeExperienceSDK: MyClassName - Provided data was null
Objective-C
The log messages from the Adobe Experience SDK are printed to the Apple System Log facility and use a common format that contains the tag AdobeExperienceSDK
. For example, if logging an error message using ACPCore.log()
, the printed output looks like [AdobeExperienceSDK ERROR <tag>]: message[AEP SDK ERROR - <testLabel>] Test message
.
Syntax
Copied to your clipboard+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;
Example
Copied to your clipboard[ACPCore log: ACPMobileLogLevelDebug, tag:@"MyClassName", message:@"Provided data was nil"];
Output
Copied to your clipboard[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
Swift
Syntax
Copied to your clipboard+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;
Example
Copied to your clipboardACPCore.log(ACPMobileLogLevel.debug, tag: "MyClassName", message: "Provided data was nil");
Output
Copied to your clipboard[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
JavaScript
The log messages from the Adobe Experience SDK are printed to the Log facility and use a common format that contains the tag ACPMobileLogLevel
.
Example
Copied to your clipboardACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");
Note: ACPMobileLogLevel
contains the following getters:
Copied to your clipboardconst ERROR = "ACP_LOG_LEVEL_ERROR";const WARNING = "ACP_LOG_LEVEL_WARNING";const DEBUG = "ACP_LOG_LEVEL_DEBUG";const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";
C#
The log messages from the Adobe Experience SDK are printed to the Log facility and use a common format that contains the tag AdobeExperienceSDK
.
iOS syntax
Copied to your clipboardACPCore.Log(ACPMobileLogLevel.Error, "xamarin tag", "xamarin message");
Copied to your clipboard[AdobeExperienceSDK ERROR <xamarin tag>]: xamarin message
Android syntax
Copied to your clipboardACPCore.Log(LoggingMode.Error, "xamarin tag", "xamarin message");
Copied to your clipboard[AdobeExperienceSDK] xamarin tag - xamarin message
Java
The MobileCore
logging APIs use the android.util.Log
APIs to log messages to Android. Based on the LoggingMode
that is passed to MobileCore.log()
, the following Android method is called:
LoggingMode.VERBOSE
usesandroid.util.Log.v
LoggingMode.DEBUG
usesandroid.util.Log.d
LoggingMode.WARNING
usesandroid.util.Log.w
LoggingMode.ERROR
usesandroid.util.Log.e
All log messages from the Adobe Experience SDK to Android use the same log tag of AdobeExperienceSDK
. For example, if logging an error message is using MobileCore.log()
, the call to android.util.Log.e
looks like Log.e("AdobeExperienceSDK", tag + " - " + message)
.
Syntax
Copied to your clipboardpublic static void log(final LoggingMode mode, final String tag, final String message)
Example
Copied to your clipboardMobileCore.log(LoggingMode.DEBUG, "MyClassName", "Provided data was null");
Output
Copied to your clipboardD/AdobeExperienceSDK: MyClassName - Provided data was null
Objective-C
The log messages from the Adobe Experience SDK are printed to the Apple System Log facility and use a common format that contains the tag AdobeExperienceSDK
. For example, if logging an error message using ACPCore.log()
, the printed output looks like [AdobeExperienceSDK ERROR <tag>]: message[AEP SDK ERROR - <testLabel>] Test message
.
Syntax
Copied to your clipboard+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;
Example
Copied to your clipboard[ACPCore log: ACPMobileLogLevelDebug, tag:@"MyClassName", message:@"Provided data was nil"];
Output
Copied to your clipboard[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
Swift
Syntax
Copied to your clipboard+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;
Example
Copied to your clipboardACPCore.log(ACPMobileLogLevel.debug, tag: "MyClassName", message: "Provided data was nil");
Output
Copied to your clipboard[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
JavaScript
The log messages from the Adobe Experience SDK are printed to the Log facility and use a common format that contains the tag ACPMobileLogLevel
.
Example
Copied to your clipboardACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");
Note: ACPMobileLogLevel
contains the following getters:
Copied to your clipboardconst ERROR = "ACP_LOG_LEVEL_ERROR";const WARNING = "ACP_LOG_LEVEL_WARNING";const DEBUG = "ACP_LOG_LEVEL_DEBUG";const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";
C#
The log messages from the Adobe Experience SDK are printed to the Log facility and use a common format that contains the tag AdobeExperienceSDK
.
iOS syntax
Copied to your clipboardACPCore.Log(ACPMobileLogLevel.Error, "xamarin tag", "xamarin message");
Copied to your clipboard[AdobeExperienceSDK ERROR <xamarin tag>]: xamarin message
Android syntax
Copied to your clipboardACPCore.Log(LoggingMode.Error, "xamarin tag", "xamarin message");
Copied to your clipboard[AdobeExperienceSDK] xamarin tag - xamarin message
registerExtension(s)
Extensions are registered with Mobile Core so that they can dispatch and listen for events.
Extension registration is mandatory. Attempting to make extension-specific API calls without registering the extension will lead to undefined behavior.
The following code snippets demonstrate how you can import and register the Mobile Core and Profile extensions. You can also see, for reference, how Identity, Lifecycle, Signal, Profile, and other extensions are imported and registered.
After you register the extensions, call the start
API in Mobile Core to initialize the SDK as shown below. This step is required to boot up the SDK for event processing. The following code snippet is provided as a sample reference.
Java
Example
Copied to your clipboardimport com.adobe.marketing.mobile.AdobeCallback;import com.adobe.marketing.mobile.Identity;import com.adobe.marketing.mobile.InvalidInitException;import com.adobe.marketing.mobile.Lifecycle;import com.adobe.marketing.mobile.LoggingMode;import com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Signal;import com.adobe.marketing.mobile.UserProfile;...import android.app.Application;...public class MainApp extends Application {...@Overridepublic void on Create(){super.onCreate();MobileCore.setApplication(this);MobileCore.setLogLevel(LoggingMode.DEBUG);...try {UserProfile.registerExtension();Identity.registerExtension();Lifecycle.registerExtension();Signal.registerExtension();MobileCore.start(new AdobeCallback () {@Overridepublic void call(Object o) {MobileCore.configureWithAppID("<your_environment_id_from_Launch>");}});} catch (InvalidInitException e) {...}}}
The following snippet shows an example of how to add the initialization code. Note that this may need to be adjusted, depending on how your application is structured.
Objective-C
Example
Copied to your clipboard#import "AppDelegate.h"#import "ACPCore.h"#import "ACPUserProfile.h"#import "ACPIdentity.h"#import "ACPLifecycle.h"#import "ACPSignal.h"...@implementation AppDelegate-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[ACPCore setLogLevel:ACPMobileLogLevelDebug];[ACPCore configureWithAppId:@"<your_environment_id_from_Launch>"];...[ACPUserProfile registerExtension];[ACPIdentity registerExtension];[ACPLifecycle registerExtension];[ACPSignal registerExtension];const UIApplicationState appState = application.applicationState;[ACPCore start:^{// only start lifecycle if the application is not in the backgroundif (appState != UIApplicationStateBackground) {[ACPCore lifecycleStart:nil];}}];...return YES;}@end
Swift
Example
Copied to your clipboardimport ACPCoreimport ACPUserProfile...@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?func application(_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool{ACPCore.setLogLevel(.debug)ACPCore.configure(withAppId: "<your_environment_id_from_Launch>")...ACPUserProfile.registerExtension()ACPIdentity.registerExtension()ACPLifecycle.registerExtension()ACPSignal.registerExtension()ACPCore.start {ACPCore.lifecycleStart(nil)}...return true}}
For React Native apps, initialize the SDK using native code in your AppDelegate
(iOS) and MainApplication
(Android).
iOS
Copied to your clipboard#import "ACPCore.h"#import "ACPUserProfile.h"#import "ACPIdentity.h"#import "ACPLifecycle.h"#import "ACPSignal.h"...@implementation AppDelegate-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[ACPCore setLogLevel:ACPMobileLogLevelDebug];[ACPCore configureWithAppId:@"<your_environment_id_from_Launch>"];[ACPUserProfile registerExtension];[ACPIdentity registerExtension];[ACPLifecycle registerExtension];[ACPSignal registerExtension];const UIApplicationState appState = application.applicationState;[ACPCore start:^{// only start lifecycle if the application is not in the backgroundif (appState != UIApplicationStateBackground) {[ACPCore lifecycleStart:nil];}}];...return YES;}@end
Android
Copied to your clipboardimport com.adobe.marketing.mobile.AdobeCallback;import com.adobe.marketing.mobile.Identity;import com.adobe.marketing.mobile.InvalidInitException;import com.adobe.marketing.mobile.Lifecycle;import com.adobe.marketing.mobile.LoggingMode;import com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Signal;import com.adobe.marketing.mobile.UserProfile;...import android.app.Application;...public class MainApplication extends Application implements ReactApplication {...@Overridepublic void on Create(){super.onCreate();...MobileCore.setApplication(this);MobileCore.setLogLevel(LoggingMode.DEBUG);MobileCore.setWrapperType(WrapperType.REACT_NATIVE);try {UserProfile.registerExtension();Identity.registerExtension();Lifecycle.registerExtension();Signal.registerExtension();MobileCore.start(new AdobeCallback () {@Overridepublic void call(Object o) {MobileCore.configureWithAppID("<your_environment_id_from_Launch>");}});} catch (InvalidInitException e) {...}}}
Dart
For Flutter apps, initialize the SDK using native code in your AppDelegate
and MainApplication
in iOS and Android, respectively.
The initialization code is located in the Flutter ACPCore Github README.
For Cordova apps, initialize the SDK using native code in your AppDelegate
and MainApplication
in iOS and Android, respectively.
iOS
Copied to your clipboard// Import the SDK#import "ACPCore.h"#import "ACPLifecycle.h"#import "ACPIdentity.h"#import "ACPSignal.h"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// make sure to set the wrapper type at the beginning of initialization[ACPCore setWrapperType:ACPMobileWrapperTypeCordova];//...[ACPCore configureWithAppId:@"yourAppId"];[ACPIdentity registerExtension];[ACPLifecycle registerExtension];[ACPSignal registerExtension];// Register any additional extensions[ACPCore start:nil];}
Android
Copied to your clipboard// Import the SDKimport com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Identity;import com.adobe.marketing.mobile.Lifecycle;import com.adobe.marketing.mobile.Signal;import com.adobe.marketing.mobile.WrapperType;@Overridepublic void onCreate() {//...MobileCore.setApplication(this);MobileCore.configureWithAppID("yourAppId");// make sure to set the wrapper type at the beginning of initializationMobileCore.setWrapperType(WrapperType.CORDOVA);try {Identity.registerExtension();Lifecycle.registerExtension();Signal.registerExtension();// Register any additional extensions} catch (Exception e) {// handle exception}MobileCore.start(null);}
C#
For Unity apps, initialize the SDK using the following code in the start function of the MainScript
.
Copied to your clipboardusing com.adobe.marketing.mobile;using using AOT;public class MainScript : MonoBehaviour{[MonoPInvokeCallback(typeof(AdobeStartCallback))]public static void HandleStartAdobeCallback(){ACPCore.ConfigureWithAppID("1423ae38-8385-8963-8693-28375403491d");}// Start is called before the first frame updatevoid Start(){if (Application.platform == RuntimePlatform.Android) {ACPCore.SetApplication();}ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);ACPCore.SetWrapperType();ACPIdentity.registerExtension();ACPLifecycle.registerExtension();ACPSignal.registerExtension();ACPCore.Start(HandleStartAdobeCallback);}}
C#
For Xamarin Forms applications, the SDK initialization differs, depending on the platform being targeted.
iOS
Copied to your clipboardusing Com.Adobe.Marketing.Mobile;[Register("AppDelegate")]public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate{//// This method is invoked when the application has loaded and is ready to run. In this// method you should instantiate the window, load the UI into it and then make the window// visible.//// You have 17 seconds to return from this method, or iOS will terminate your application.//public override bool FinishedLaunching(UIApplication app, NSDictionary options){global::Xamarin.Forms.Forms.Init();LoadApplication(new App());// set the wrapper typeACPCore.SetWrapperType(ACPMobileWrapperType.Xamarin);// set launch configACPCore.ConfigureWithAppID("your-app-id");// register SDK extensionsACPIdentity.RegisterExtension();ACPLifecycle.RegisterExtension();ACPSignal.RegisterExtension();// start coreACPCore.Start(null);}
Android
Copied to your clipboardusing Com.Adobe.Marketing.Mobile;[Activity(Label = "TestApp", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity{protected override void OnCreate(Bundle savedInstanceState){base.OnCreate(savedInstanceState);global::Xamarin.Forms.Forms.Init(this, savedInstanceState);LoadApplication(new App());// set the wrapper typeACPCore.SetWrapperType(WrapperType.Xamarin);// register SDK extensionsACPCore.Application = this.Application;ACPIdentity.RegisterExtension();ACPLifecycle.RegisterExtension();ACPSignal.RegisterExtension();// start coreACPCore.Start(null);}
After you register the extensions, call the start
API in Mobile Core to initialize the SDK as shown below. This step is required to boot up the SDK for event processing. The following code snippet is provided as a sample reference.
Java
Example
Copied to your clipboardimport com.adobe.marketing.mobile.AdobeCallback;import com.adobe.marketing.mobile.Identity;import com.adobe.marketing.mobile.InvalidInitException;import com.adobe.marketing.mobile.Lifecycle;import com.adobe.marketing.mobile.LoggingMode;import com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Signal;import com.adobe.marketing.mobile.UserProfile;...import android.app.Application;...public class MainApp extends Application {...@Overridepublic void on Create(){super.onCreate();MobileCore.setApplication(this);MobileCore.setLogLevel(LoggingMode.DEBUG);...try {UserProfile.registerExtension();Identity.registerExtension();Lifecycle.registerExtension();Signal.registerExtension();MobileCore.start(new AdobeCallback () {@Overridepublic void call(Object o) {MobileCore.configureWithAppID("<your_environment_id_from_Launch>");}});} catch (InvalidInitException e) {...}}}
The following snippet shows an example of how to add the initialization code. Note that this may need to be adjusted, depending on how your application is structured.
Objective-C
Example
Copied to your clipboard#import "AppDelegate.h"#import "ACPCore.h"#import "ACPUserProfile.h"#import "ACPIdentity.h"#import "ACPLifecycle.h"#import "ACPSignal.h"...@implementation AppDelegate-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[ACPCore setLogLevel:ACPMobileLogLevelDebug];[ACPCore configureWithAppId:@"<your_environment_id_from_Launch>"];...[ACPUserProfile registerExtension];[ACPIdentity registerExtension];[ACPLifecycle registerExtension];[ACPSignal registerExtension];const UIApplicationState appState = application.applicationState;[ACPCore start:^{// only start lifecycle if the application is not in the backgroundif (appState != UIApplicationStateBackground) {[ACPCore lifecycleStart:nil];}}];...return YES;}@end
Swift
Example
Copied to your clipboardimport ACPCoreimport ACPUserProfile...@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?func application(_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool{ACPCore.setLogLevel(.debug)ACPCore.configure(withAppId: "<your_environment_id_from_Launch>")...ACPUserProfile.registerExtension()ACPIdentity.registerExtension()ACPLifecycle.registerExtension()ACPSignal.registerExtension()ACPCore.start {ACPCore.lifecycleStart(nil)}...return true}}
For React Native apps, initialize the SDK using native code in your AppDelegate
(iOS) and MainApplication
(Android).
iOS
Copied to your clipboard#import "ACPCore.h"#import "ACPUserProfile.h"#import "ACPIdentity.h"#import "ACPLifecycle.h"#import "ACPSignal.h"...@implementation AppDelegate-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[ACPCore setLogLevel:ACPMobileLogLevelDebug];[ACPCore configureWithAppId:@"<your_environment_id_from_Launch>"];[ACPUserProfile registerExtension];[ACPIdentity registerExtension];[ACPLifecycle registerExtension];[ACPSignal registerExtension];const UIApplicationState appState = application.applicationState;[ACPCore start:^{// only start lifecycle if the application is not in the backgroundif (appState != UIApplicationStateBackground) {[ACPCore lifecycleStart:nil];}}];...return YES;}@end
Android
Copied to your clipboardimport com.adobe.marketing.mobile.AdobeCallback;import com.adobe.marketing.mobile.Identity;import com.adobe.marketing.mobile.InvalidInitException;import com.adobe.marketing.mobile.Lifecycle;import com.adobe.marketing.mobile.LoggingMode;import com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Signal;import com.adobe.marketing.mobile.UserProfile;...import android.app.Application;...public class MainApplication extends Application implements ReactApplication {...@Overridepublic void on Create(){super.onCreate();...MobileCore.setApplication(this);MobileCore.setLogLevel(LoggingMode.DEBUG);MobileCore.setWrapperType(WrapperType.REACT_NATIVE);try {UserProfile.registerExtension();Identity.registerExtension();Lifecycle.registerExtension();Signal.registerExtension();MobileCore.start(new AdobeCallback () {@Overridepublic void call(Object o) {MobileCore.configureWithAppID("<your_environment_id_from_Launch>");}});} catch (InvalidInitException e) {...}}}
Dart
For Flutter apps, initialize the SDK using native code in your AppDelegate
and MainApplication
in iOS and Android, respectively.
The initialization code is located in the Flutter ACPCore Github README.
For Cordova apps, initialize the SDK using native code in your AppDelegate
and MainApplication
in iOS and Android, respectively.
iOS
Copied to your clipboard// Import the SDK#import "ACPCore.h"#import "ACPLifecycle.h"#import "ACPIdentity.h"#import "ACPSignal.h"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// make sure to set the wrapper type at the beginning of initialization[ACPCore setWrapperType:ACPMobileWrapperTypeCordova];//...[ACPCore configureWithAppId:@"yourAppId"];[ACPIdentity registerExtension];[ACPLifecycle registerExtension];[ACPSignal registerExtension];// Register any additional extensions[ACPCore start:nil];}
Android
Copied to your clipboard// Import the SDKimport com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Identity;import com.adobe.marketing.mobile.Lifecycle;import com.adobe.marketing.mobile.Signal;import com.adobe.marketing.mobile.WrapperType;@Overridepublic void onCreate() {//...MobileCore.setApplication(this);MobileCore.configureWithAppID("yourAppId");// make sure to set the wrapper type at the beginning of initializationMobileCore.setWrapperType(WrapperType.CORDOVA);try {Identity.registerExtension();Lifecycle.registerExtension();Signal.registerExtension();// Register any additional extensions} catch (Exception e) {// handle exception}MobileCore.start(null);}
C#
For Unity apps, initialize the SDK using the following code in the start function of the MainScript
.
Copied to your clipboardusing com.adobe.marketing.mobile;using using AOT;public class MainScript : MonoBehaviour{[MonoPInvokeCallback(typeof(AdobeStartCallback))]public static void HandleStartAdobeCallback(){ACPCore.ConfigureWithAppID("1423ae38-8385-8963-8693-28375403491d");}// Start is called before the first frame updatevoid Start(){if (Application.platform == RuntimePlatform.Android) {ACPCore.SetApplication();}ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);ACPCore.SetWrapperType();ACPIdentity.registerExtension();ACPLifecycle.registerExtension();ACPSignal.registerExtension();ACPCore.Start(HandleStartAdobeCallback);}}
C#
For Xamarin Forms applications, the SDK initialization differs, depending on the platform being targeted.
iOS
Copied to your clipboardusing Com.Adobe.Marketing.Mobile;[Register("AppDelegate")]public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate{//// This method is invoked when the application has loaded and is ready to run. In this// method you should instantiate the window, load the UI into it and then make the window// visible.//// You have 17 seconds to return from this method, or iOS will terminate your application.//public override bool FinishedLaunching(UIApplication app, NSDictionary options){global::Xamarin.Forms.Forms.Init();LoadApplication(new App());// set the wrapper typeACPCore.SetWrapperType(ACPMobileWrapperType.Xamarin);// set launch configACPCore.ConfigureWithAppID("your-app-id");// register SDK extensionsACPIdentity.RegisterExtension();ACPLifecycle.RegisterExtension();ACPSignal.RegisterExtension();// start coreACPCore.Start(null);}
Android
Copied to your clipboardusing Com.Adobe.Marketing.Mobile;[Activity(Label = "TestApp", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity{protected override void OnCreate(Bundle savedInstanceState){base.OnCreate(savedInstanceState);global::Xamarin.Forms.Forms.Init(this, savedInstanceState);LoadApplication(new App());// set the wrapper typeACPCore.SetWrapperType(WrapperType.Xamarin);// register SDK extensionsACPCore.Application = this.Application;ACPIdentity.RegisterExtension();ACPLifecycle.RegisterExtension();ACPSignal.RegisterExtension();// start coreACPCore.Start(null);}
registerURLHandler
Mobile SDK allows you to add a callback function that is triggered before the open url
action occurs. If the callback function returns Yes, the SDK does not complete the open url
action. If the callback function returns No, the SDK completes the open url
action.
setAdvertisingIdentifier
The advertising ID is preserved between app upgrades, is saved and restored during the standard application backup process, available via Signals, and is removed at uninstall.
For more information about identity in Mobile Core, please read the documentation on the identity APIs.
setAppGroup
You can use the setAppGroup
method to set the app group, which is used to share user defaults and files among the containing app and the extension apps. Please note that this method is only supported on iOS versions of Mobile Core.
This API must be called in AppDidFinishLaunching
and before any other interactions with the Adobe Experience SDK have happened. Only the first call to this function will have any effect.
Swift
Syntax
Copied to your clipboardpublic static func setAppGroup(_ group: String?)
Example
Copied to your clipboardACPCore.setAppGroup("app-group-id")
Objective-C
Syntax
Copied to your clipboardpublic static func setAppGroup(_ group: String?)
Example
Copied to your clipboard[ACPCore setAppGroup:@"app-group-id"];
Swift
Syntax
Copied to your clipboardpublic static func setAppGroup(_ group: String?)
Example
Copied to your clipboardACPCore.setAppGroup("app-group-id")
Objective-C
Syntax
Copied to your clipboardpublic static func setAppGroup(_ group: String?)
Example
Copied to your clipboard[ACPCore setAppGroup:@"app-group-id"];
setApplication
When building Android applications, the android.app.Application
reference must be passed to Mobile SDK, which allows Mobile SDK to access the android.app.Context
and monitor the lifecycle of the Android application.
Android applications must call MobileCore.setApplication()
before calling any other Mobile SDK API.
You can use the setApplication
method to pass the Android Application
instance to Mobile SDK. Please note that this method is only supported on Android versions of Mobile Core.
setLogLevel
The logging APIs allow log messages to be tagged and filtered with the Mobile SDK log messages. This allows application developers to filter the logged messages based on the current logging mode.
Application developers can use the setLogLevel
method to filter the log messages that are coming from the Mobile SDK.
From least to most verbose, the order of Mobile SDK logging modes is as follows:
- ERROR
- WARNING
- DEBUG
- VERBOSE / TRACE
When debugging on iOS, you can use LogLevel.verbose
to enable all the logging messages that are coming from Mobile SDK and partner extensions. Similarly, on Android, you can use LoggingMode.VERBOSE
to enable all the logging messages that are coming from Mobile SDK and partner extensions.
In a production application, you should use a less verbose logging mode, such as error-level logging.
By default, Mobile SDK logging mode is set to LoggingMode.ERROR
for Android and LogLevel.error
on iOS.
On Android, Mobile SDK uses the android.util.Log
class to log messages.
On iOS, Mobile SDK uses NSLog
to messages to Apple System Log facility.
Swift
Syntax
Copied to your clipboard(void) setLogLevel: (ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardimport ACPCoreACPCore.setLogLevel(ACPMobileLogLevel.verbose);
Objective-C
Syntax
Copied to your clipboard(void) setLogLevel: (ACPMobileLogLevel) logLevel;
Example
Copied to your clipboard#import "ACPCore.h"[ACPCore setLogLevel: ACPMobileLogLevelVerbose];
Cordova
From least to most verbose, the order of Mobile SDK logging modes is as follows:
- ACPCore.ACPMobileLogLevelError
- ACPCore.ACPMobileLogLevelWarning
- ACPCore.ACPMobileLogLevelDebug
- ACPCore.ACPMobileLogLevelVerbose
Syntax
Copied to your clipboardACPCore.setLogLevel = function(logLevel, success, fail);
Example
Copied to your clipboardACPCore.setLogLevel(ACPCore.ACPMobileLogLevelVerbose, successCallback, errorCallback);MobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);
C#
From least to most verbose, the order of Mobile SDK logging modes is as follows:
- ACPCore.ACPMobileLogLevel.ERROR
- ACPCore.ACPMobileLogLevel.WARNING
- ACPCore.ACPMobileLogLevel.DEBUG
- ACPCore.ACPMobileLogLevel.VERBOSE
Syntax
Copied to your clipboardpublic static void SetLogLevel(ACPMobileLogLevel logLevel)
Example
Copied to your clipboardACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.ERROR);
C#
From least to most verbose, the order of Mobile SDK logging modes is as follows for iOS:
- ACPMobileLogLevel.Error;
- ACPMobileLogLevel.Warning;
- ACPMobileLogLevel.Debug;
- ACPMobileLogLevel.Verbose;
From least to most verbose, the order of Mobile SDK logging modes is as follows for Android:
- LoggingMode.Error;
- LoggingMode.Warning;
- LoggingMode.Debug;
- LoggingMode.Verbose;
iOS syntax
Copied to your clipboardpublic static ACPMobileLogLevel LogLevel { get, set }
Android syntax
Copied to your clipboardpublic unsafe static LoggingMode LogLevel { get, set }
iOS example
Copied to your clipboardACPCore.LogLevel = ACPMobileLogLevel.Verbose;
Android example
Copied to your clipboardACPCore.LogLevel = LoggingMode.Verbose;
Java
Syntax
Copied to your clipboardpublic static void setLogLevel(LoggingMode mode)
Example
Copied to your clipboardimport com.adobe.marketing.mobile.LoggingMode;import com.adobe.marketing.mobile.MobileCore;MobileCore.setLogLevel(LoggingMode.VERBOSE);
Swift
Syntax
Copied to your clipboard(void) setLogLevel: (ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardimport ACPCoreACPCore.setLogLevel(ACPMobileLogLevel.verbose);
Objective-C
Syntax
Copied to your clipboard(void) setLogLevel: (ACPMobileLogLevel) logLevel;
Example
Copied to your clipboard#import "ACPCore.h"[ACPCore setLogLevel: ACPMobileLogLevelVerbose];
Javascript
Syntax
Copied to your clipboard(void) setLogLevel: (ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardimport {ACPMobileLogLevel} from '@adobe/react-native-acpcore';ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
Dart
Syntax
Copied to your clipboard(void) setLogLevel: (ACPMobileLogLevel) logLevel;
Example
Copied to your clipboardimport 'package:flutter_acpcore/src/acpmobile_logging_level.dart';FlutterACPCore.setLogLevel(ACPLoggingLevel.VERBOSE);
Cordova
From least to most verbose, the order of Mobile SDK logging modes is as follows:
- ACPCore.ACPMobileLogLevelError
- ACPCore.ACPMobileLogLevelWarning
- ACPCore.ACPMobileLogLevelDebug
- ACPCore.ACPMobileLogLevelVerbose
Syntax
Copied to your clipboardACPCore.setLogLevel = function(logLevel, success, fail);
Example
Copied to your clipboardACPCore.setLogLevel(ACPCore.ACPMobileLogLevelVerbose, successCallback, errorCallback);MobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);
C#
From least to most verbose, the order of Mobile SDK logging modes is as follows:
- ACPCore.ACPMobileLogLevel.ERROR
- ACPCore.ACPMobileLogLevel.WARNING
- ACPCore.ACPMobileLogLevel.DEBUG
- ACPCore.ACPMobileLogLevel.VERBOSE
Syntax
Copied to your clipboardpublic static void SetLogLevel(ACPMobileLogLevel logLevel)
Example
Copied to your clipboardACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.ERROR);
C#
From least to most verbose, the order of Mobile SDK logging modes is as follows for iOS:
- ACPMobileLogLevel.Error;
- ACPMobileLogLevel.Warning;
- ACPMobileLogLevel.Debug;
- ACPMobileLogLevel.Verbose;
From least to most verbose, the order of Mobile SDK logging modes is as follows for Android:
- LoggingMode.Error;
- LoggingMode.Warning;
- LoggingMode.Debug;
- LoggingMode.Verbose;
iOS syntax
Copied to your clipboardpublic static ACPMobileLogLevel LogLevel { get, set }
Android syntax
Copied to your clipboardpublic unsafe static LoggingMode LogLevel { get, set }
iOS example
Copied to your clipboardACPCore.LogLevel = ACPMobileLogLevel.Verbose;
Android example
Copied to your clipboardACPCore.LogLevel = LoggingMode.Verbose;
setPushIdentifier
This API sets the device token for push notifications in the SDK. If the current SDK privacy status is optedout
, the push identifier is not set.
You should call setPushIdentifier
on each application launch to ensure the most up-to-date device token is set to the SDK. If no device token is available, null
/nil
should be passed.
Java
Syntax
Copied to your clipboardpublic static void setPushIdentifier(final String pushIdentifier);
- pushIdentifier is a string that contains the device token for push notifications.
Example
Copied to your clipboard//Retrieve the token from either GCM or FCM, and pass it to the SDKMobileCore.setPushIdentifier(token);
Swift
Syntax
Copied to your clipboard@objc(setPushIdentifier:)public static func setPushIdentifier(_ deviceToken: Data?)
- deviceToken is a string that contains the device token for push notifications.
Example
Copied to your clipboard// Set the deviceToken that the APNs has assigned to the deviceMobileCore.setPushIdentifier(deviceToken)
Objective-C
Syntax
Copied to your clipboardpublic static func setPushIdentifier(_ deviceToken: Data?)
- deviceToken is a string that contains the device token for push notifications.
Example
Copied to your clipboard// Set the deviceToken that the APNS has assigned to the device[ACPCore setPushIdentifier:deviceToken];
Java
Syntax
Copied to your clipboardpublic static void setPushIdentifier(final String pushIdentifier);
- pushIdentifier is a string that contains the device token for push notifications.
Example
Copied to your clipboard//Retrieve the token from either GCM or FCM, and pass it to the SDKMobileCore.setPushIdentifier(token);
Swift
Syntax
Copied to your clipboard@objc(setPushIdentifier:)public static func setPushIdentifier(_ deviceToken: Data?)
- deviceToken is a string that contains the device token for push notifications.
Example
Copied to your clipboard// Set the deviceToken that the APNs has assigned to the deviceMobileCore.setPushIdentifier(deviceToken)
Objective-C
Syntax
Copied to your clipboardpublic static func setPushIdentifier(_ deviceToken: Data?)
- deviceToken is a string that contains the device token for push notifications.
Example
Copied to your clipboard// Set the deviceToken that the APNS has assigned to the device[ACPCore setPushIdentifier:deviceToken];
setSmallIconResourceID / setLargeIconResourceID
You can set the small and large icons that will be used for notifications that are created by the SDK. The small icon appears in the status bar and is the secondary image that is displayed when the user sees the complete notification in the notification center. The large icon is the primary image that is displayed when the user sees the complete notification in the notification center. Please note that this method is only supported on Android versions of Mobile Core.
Java
setSmallIconResourceID
Syntax
Copied to your clipboardpublic static void setSmallIconResourceID(int resourceID)
Example
Copied to your clipboardMobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);
setLargeIconResourceID
Syntax
Copied to your clipboardpublic static void setLargeIconResourceID(int resourceID)
Example
Copied to your clipboardMobileCore.setLargeIconResourceID(R.mipmap.ic_launcher_round);
C#
setSmallIconResourceID
Syntax
Copied to your clipboardpublic unsafe static void SetSmallIconResourceID (int resourceID);
Example
Copied to your clipboardACPCore.SetSmallIconResourceID(Resource.Mipmap.icon_round);
setLargeIconResourceID
Syntax
Copied to your clipboardpublic unsafe static void SetLargeIconResourceID (int resourceID);
Example
Copied to your clipboardACPCore.SetLargeIconResourceID(Resource.Mipmap.icon_round);
Java
setSmallIconResourceID
Syntax
Copied to your clipboardpublic static void setSmallIconResourceID(int resourceID)
Example
Copied to your clipboardMobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);
setLargeIconResourceID
Syntax
Copied to your clipboardpublic static void setLargeIconResourceID(int resourceID)
Example
Copied to your clipboardMobileCore.setLargeIconResourceID(R.mipmap.ic_launcher_round);
C#
setSmallIconResourceID
Syntax
Copied to your clipboardpublic unsafe static void SetSmallIconResourceID (int resourceID);
Example
Copied to your clipboardACPCore.SetSmallIconResourceID(Resource.Mipmap.icon_round);
setLargeIconResourceID
Syntax
Copied to your clipboardpublic unsafe static void SetLargeIconResourceID (int resourceID);
Example
Copied to your clipboardACPCore.SetLargeIconResourceID(Resource.Mipmap.icon_round);
trackAction
Actions are events that occur in your application. You can use the trackAction
method to track and measure an action. Each action has one or more corresponding metrics that are incremented each time the event occurs. For example, you can use an action to track new subscriptions, every time an article is viewed, or every time a level is completed.
You want to use the trackAction
method when you want to track an occurring event. In addition to the action name, you can also send context data with each trackAction
call.
If you installed and configured the Adobe Analytics extension, this method sends an Adobe Analytics action tracking hit with the provided optional context data.
Java
Syntax
Copied to your clipboardpublic static void trackAction(final String action, final Map<String, String> contextData)
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardMap<String, String> additionalContextData = new HashMap<String, String>();additionalContextData.put("customKey", "value");MobileCore.trackAction("loginClicked", additionalContextData);
Swift
Syntax
Copied to your clipboard@objc(trackAction:data:)static func track(action: String?, data: [String: Any]?)
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardACPCore.track(action: "action name", data: ["key": "value"])
Objective-C
Syntax
Copied to your clipboard+ (void) trackAction: (nullable NSString*) action data: (nullable NSDictionary*) contextData;
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboard[ACPCore trackAction:@"action name" data:@{@"key":@"value"}];
Dart
Syntax
Copied to your clipboardFuture<void> trackAction (String action, {Map<String, String> contextData});
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardFlutterACPCore.trackAction("action name", data: {"key": "value"});
Cordova
Syntax
Copied to your clipboardACPCore.trackAction = function(action, contextData, success, fail);
- action contains the name of the action to track.
- contextData contains the context data to attach on this hit.
- success callback is invoked when trackAction executes successfully.
- fail callback is invoked when trackAction fails.
Example
Copied to your clipboardACPCore.trackAction("cordovaAction", {"cordovaKey":"cordovaValue"}, successCallback, errorCallback);
C#
Syntax
Copied to your clipboardpublic static void TrackAction(string name, Dictionary<string, string> contextDataDict)
- name contains the name of the action to track.
- contextDataDict contains the context data to attach on the hit.
Example
Copied to your clipboardvar contextData = new Dictionary<string, string>();contextData.Add("key", "value");ACPCore.TrackAction("action", contextData);
C#
iOS syntax
Copied to your clipboardpublic static void TrackAction (string action, NSMutableDictionary<NSString, NSString> data);
- action contains the name of the action to track.
- data contains the context data to attach on the hit.
Android syntax
Copied to your clipboardpublic unsafe static void TrackAction (string action, IDictionary<string, string> contextData);
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
iOS example
Copied to your clipboardvar data = new NSMutableDictionary<NSString, NSString>{["key"] = new NSString("value")};ACPCore.TrackAction("action", data);
Android example
Copied to your clipboardvar data = new Dictionary<string, string>();data.Add("key", "value");ACPCore.TrackAction("action", data);
Java
Syntax
Copied to your clipboardpublic static void trackAction(final String action, final Map<String, String> contextData)
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardMap<String, String> additionalContextData = new HashMap<String, String>();additionalContextData.put("customKey", "value");MobileCore.trackAction("loginClicked", additionalContextData);
Swift
Syntax
Copied to your clipboard@objc(trackAction:data:)static func track(action: String?, data: [String: Any]?)
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardACPCore.track(action: "action name", data: ["key": "value"])
Objective-C
Syntax
Copied to your clipboard+ (void) trackAction: (nullable NSString*) action data: (nullable NSDictionary*) contextData;
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboard[ACPCore trackAction:@"action name" data:@{@"key":@"value"}];
Javascript
Syntax
Copied to your clipboardtrackAction(action?: String, contextData?: { string: string });
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardACPCore.trackAction("action name", {"key": "value"});
Dart
Syntax
Copied to your clipboardFuture<void> trackAction (String action, {Map<String, String> contextData});
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardFlutterACPCore.trackAction("action name", data: {"key": "value"});
Cordova
Syntax
Copied to your clipboardACPCore.trackAction = function(action, contextData, success, fail);
- action contains the name of the action to track.
- contextData contains the context data to attach on this hit.
- success callback is invoked when trackAction executes successfully.
- fail callback is invoked when trackAction fails.
Example
Copied to your clipboardACPCore.trackAction("cordovaAction", {"cordovaKey":"cordovaValue"}, successCallback, errorCallback);
C#
Syntax
Copied to your clipboardpublic static void TrackAction(string name, Dictionary<string, string> contextDataDict)
- name contains the name of the action to track.
- contextDataDict contains the context data to attach on the hit.
Example
Copied to your clipboardvar contextData = new Dictionary<string, string>();contextData.Add("key", "value");ACPCore.TrackAction("action", contextData);
C#
iOS syntax
Copied to your clipboardpublic static void TrackAction (string action, NSMutableDictionary<NSString, NSString> data);
- action contains the name of the action to track.
- data contains the context data to attach on the hit.
Android syntax
Copied to your clipboardpublic unsafe static void TrackAction (string action, IDictionary<string, string> contextData);
- action contains the name of the action to track.
- contextData contains the context data to attach on the hit.
iOS example
Copied to your clipboardvar data = new NSMutableDictionary<NSString, NSString>{["key"] = new NSString("value")};ACPCore.TrackAction("action", data);
Android example
Copied to your clipboardvar data = new Dictionary<string, string>();data.Add("key", "value");ACPCore.TrackAction("action", data);
trackState
States represent screens or views in your application. The trackState
method needs to be called every time a new state is displayed in your application. For example, this method should be called when a user navigates from the home page to the news feed. This method sends an Adobe Analytics state tracking hit with optional context data.
If you installed and configured the Adobe Analytics extension, the trackState
method increments page views and an Adobe Analytics state tracking hit with the provided optional context data.
Java
In Android, trackState
is typically called every time a new Activity
is loaded.
Syntax
Copied to your clipboardpublic static void trackState(final String state, final Map<String, String> contextData)
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardMap<String, String> additionalContextData = new HashMap<String, String>();additionalContextData.put("customKey", "value");MobileCore.trackState("homePage", additionalContextData);
Swift
Syntax
Copied to your clipboard+ (void) trackState: (nullable NSString*) state data: (nullable NSDictionary*) contextData;
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardACPCore.trackState("state name", data: ["key": "value"])
Objective-C
Syntax
Copied to your clipboard(void) trackState: (nullable NSString*) state data: (nullable NSDictionary*) contextData;
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboard[ACPCore trackState:@"state name" data:@{@"key":@"value"}];
Dart
Syntax
Copied to your clipboardFuture<void> trackState (String state, {Map<String, String> contextData});
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardFlutterACPCore.trackState("state name", data: {"key1: "value"})
Cordova
Syntax
Copied to your clipboardACPCore.trackState = function(state, contextData, success, fail);
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
- success callback is invoked when trackState executes successfully.
- fail callback is invoked when trackState fails.
Example
Copied to your clipboardACPCore.trackState("cordovaState", {"cordovaKey":"cordovaValue"}, successCallback, errorCallback);
C#
Syntax
Copied to your clipboardpublic static void TrackState(string name, Dictionary<string, string> contextDataDict)
- state contains the name of the state to track.
- contextDataDict contains the context data to attach on the hit.
Example
Copied to your clipboardvar dict = new Dictionary<string, string>();dict.Add("key", "value");ACPCore.TrackState("state", dict);
C#
iOS syntax
Copied to your clipboardpublic static void TrackState (string state, NSMutableDictionary<NSString, NSString> data);
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Android syntax
Copied to your clipboardpublic unsafe static void TrackState (string state, IDictionary<string, string> contextData);
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
iOS example
Copied to your clipboardvar data = new NSMutableDictionary<NSString, NSString>{["key"] = new NSString("value")};ACPCore.TrackState("state", data);
Android example
Copied to your clipboardvar data = new Dictionary<string, string>();data.Add("key", "value");ACPCore.TrackState("state", data);
Java
In Android, trackState
is typically called every time a new Activity
is loaded.
Syntax
Copied to your clipboardpublic static void trackState(final String state, final Map<String, String> contextData)
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardMap<String, String> additionalContextData = new HashMap<String, String>();additionalContextData.put("customKey", "value");MobileCore.trackState("homePage", additionalContextData);
Swift
Syntax
Copied to your clipboard+ (void) trackState: (nullable NSString*) state data: (nullable NSDictionary*) contextData;
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardACPCore.trackState("state name", data: ["key": "value"])
Objective-C
Syntax
Copied to your clipboard(void) trackState: (nullable NSString*) state data: (nullable NSDictionary*) contextData;
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboard[ACPCore trackState:@"state name" data:@{@"key":@"value"}];
Javascript
Syntax
Copied to your clipboardtrackState(state?: String, contextData?: { string: string });
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardACPCore.trackState("state name", {"key": "value"});
Dart
Syntax
Copied to your clipboardFuture<void> trackState (String state, {Map<String, String> contextData});
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Example
Copied to your clipboardFlutterACPCore.trackState("state name", data: {"key1: "value"})
Cordova
Syntax
Copied to your clipboardACPCore.trackState = function(state, contextData, success, fail);
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
- success callback is invoked when trackState executes successfully.
- fail callback is invoked when trackState fails.
Example
Copied to your clipboardACPCore.trackState("cordovaState", {"cordovaKey":"cordovaValue"}, successCallback, errorCallback);
C#
Syntax
Copied to your clipboardpublic static void TrackState(string name, Dictionary<string, string> contextDataDict)
- state contains the name of the state to track.
- contextDataDict contains the context data to attach on the hit.
Example
Copied to your clipboardvar dict = new Dictionary<string, string>();dict.Add("key", "value");ACPCore.TrackState("state", dict);
C#
iOS syntax
Copied to your clipboardpublic static void TrackState (string state, NSMutableDictionary<NSString, NSString> data);
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
Android syntax
Copied to your clipboardpublic unsafe static void TrackState (string state, IDictionary<string, string> contextData);
- state contains the name of the state to track.
- contextData contains the context data to attach on the hit.
iOS example
Copied to your clipboardvar data = new NSMutableDictionary<NSString, NSString>{["key"] = new NSString("value")};ACPCore.TrackState("state", data);
Android example
Copied to your clipboardvar data = new Dictionary<string, string>();data.Add("key", "value");ACPCore.TrackState("state", data);
Public classes
Java
AdobeCallback
The AdobeCallback
class provides the interface to receive results when the asynchronous APIs perform the requested action.
Copied to your clipboardpublic interface AdobeCallback<T> {void call(final T value);}
AdobeCallbackWithError
The AdobeCallbackWithError
class provides the interface to receive results or an error when the asynchronous APIs perform the requested action.
When using this class, if the request cannot be completed within the default timeout or an unexpected error occurs, the request is stopped and the fail method is called with the corresponding AdobeError
.
Copied to your clipboardpublic interface AdobeCallbackWithError<T> extends AdobeCallback<T> {void fail(final AdobeError error);}
AdobeError
The AdobeError
class shows the errors that can be passed to an AdobeCallbackWithError
:
UNEXPECTED_ERROR
- An unexpected error occurred.CALLBACK_TIMEOUT
- The timeout was met.CALLBACK_NULL
- The provided callback function is null.EXTENSION_NOT_INITIALIZED
- The extension is not initialized.
Example
Copied to your clipboardMobileCore.getPrivacyStatus(new AdobeCallbackWithError<MobilePrivacyStatus>() {@Overridepublic void fail(final AdobeError error) {if (error == AdobeError.UNEXPECTED_ERROR) {// handle unexpected error} else if (error == AdobeError.CALLBACK_TIMEOUT) {// handle timeout error} else if (error == AdobeError.CALLBACK_NULL) {// handle null callback error} else if (error == AdobeError.EXTENSION_NOT_INITIALIZED) {// handle extension not initialized error}}@Overridepublic void call(final MobilePrivacyStatus value) {// use MobilePrivacyStatus value}});
ACPError
The ACPError
class shows the errors that can be passed to a completion handler callback from any API which uses one:
ACPErrorUnexpected
- An unexpected error occurred.ACPErrorCallbackTimeout
- The timeout was met.ACPErrorCallbackNil
- The provided callback function is nil.ACPErrorExtensionNotInitialized
- The extension is not initialized.
Example
Objective-C
Copied to your clipboard[ACPCore getSdkIdentities:^(NSString * _Nullable content, NSError * _Nullable error) {if (error) {if (error.code == ACPErrorCallbackTimeout) {// handle timeout error} else if (error.code == ACPErrorCallbackNil) {// handle nil callback error} else if (error.code == ACPErrorExtensionNotInitialized) {// handle extension not initialized error} else if (error.code == ACPErrorUnexpected) {// handle unexpected error....} else {// use privacy status}}];
Swift
Copied to your clipboardACPCore.getPrivacyStatus { (privacyStatus, error) inif let error = error {let callbackError: NSError = (error as NSError)if (callbackError.code == ACPError.callbackTimeout.rawValue) {// handle timeout error} else if (callbackError.code == ACPError.callbackNil.rawValue) {// handle nil callback error} else if (callbackError.code == ACPError.extensionNotInitialized.rawValue) {// handle extension not initialized error} else if (callbackError.code == ACPError.unexpected.rawValue) {// handle unexpected error}} else {// use privacyStatus}}
Android
IAdobeCallback
This class provides the interface to receive results when the async APIs perform the requested action.
Copied to your clipboardpublic interface IAdobeCallback : IJavaObject, IDisposable, IJavaPeerable{void Call (Java.Lang.Object p0);}
IAdobeCallbackWithError
This class provides the interface to receive results or an error when the async APIs perform the requested action. When using this class, if the request cannot be completed within the default timeout or an unexpected error occurs, the request is aborted and the fail method is called with the corresponding AdobeError.
Copied to your clipboardpublic interface IAdobeCallbackWithError : IAdobeCallback, IJavaObject, IDisposable, IJavaPeerable{void Fail (AdobeError p0);}
AdobeError
Errors which may be passed to an AdobeCallbackWithError:
UnexpectedError
- An unexpected error occurred.CallbackTimeout
- The timeout was met.CallbackNull
- The provided callback function is null.ExtensionNotInitialized
- The extension is not initialized.
Example
Copied to your clipboardACPCore.GetPrivacyStatus(new AdobeCallbackWithError());class AdobeCallbackWithError : Java.Lang.Object, IAdobeCallbackWithError{public void Call(Java.Lang.Object stringContent){if (stringContent != null){Console.WriteLine("String callback content: " + stringContent);}else{Console.WriteLine("null content in string callback");}}public void Fail(AdobeError error){if (error == AdobeError.UnexpectedError){// handle unexpected error}else if (error == AdobeError.CallbackTimeout){// handle timeout error}else if (error == AdobeError.CallbackNull){// handle null callback error}else if (error == AdobeError.ExtensionNotInitialized){// handle extension not initialized error}
iOS
ACPError
Errors which may be passed to a completion handler callback from any API which uses one:
ACPError.Unexpected
- An unexpected error occurred.ACPError.CallbackTimeout
- The timeout was met.ACPError.CallbackNil
- The provided callback function is nil.ACPError.ExtensionNotInitialized
- The extension is not initialized.
Example
Copied to your clipboardACPCore.GetPrivacyStatusWithCompletionHandler((privacyStatus, error) => {if (error != null){if ( error.Code == (int)ACPError.CallbackTimeout){// handle timeout error}else if (error.Code == (int)ACPError.CallbackNil){// handle nil callback error}else if (error.Code == (int)ACPError.ExtensionNotInitialized){// handle extension not initialized error}else if (error.Code == (int)ACPError.Unexpected){// handle unexpected error}}else{Console.WriteLine("privacy status: " + privacyStatus);}});
Java
AdobeCallback
The AdobeCallback
class provides the interface to receive results when the asynchronous APIs perform the requested action.
Copied to your clipboardpublic interface AdobeCallback<T> {void call(final T value);}
AdobeCallbackWithError
The AdobeCallbackWithError
class provides the interface to receive results or an error when the asynchronous APIs perform the requested action.
When using this class, if the request cannot be completed within the default timeout or an unexpected error occurs, the request is stopped and the fail method is called with the corresponding AdobeError
.
Copied to your clipboardpublic interface AdobeCallbackWithError<T> extends AdobeCallback<T> {void fail(final AdobeError error);}
AdobeError
The AdobeError
class shows the errors that can be passed to an AdobeCallbackWithError
:
UNEXPECTED_ERROR
- An unexpected error occurred.CALLBACK_TIMEOUT
- The timeout was met.CALLBACK_NULL
- The provided callback function is null.EXTENSION_NOT_INITIALIZED
- The extension is not initialized.
Example
Copied to your clipboardMobileCore.getPrivacyStatus(new AdobeCallbackWithError<MobilePrivacyStatus>() {@Overridepublic void fail(final AdobeError error) {if (error == AdobeError.UNEXPECTED_ERROR) {// handle unexpected error} else if (error == AdobeError.CALLBACK_TIMEOUT) {// handle timeout error} else if (error == AdobeError.CALLBACK_NULL) {// handle null callback error} else if (error == AdobeError.EXTENSION_NOT_INITIALIZED) {// handle extension not initialized error}}@Overridepublic void call(final MobilePrivacyStatus value) {// use MobilePrivacyStatus value}});
ACPError
The ACPError
class shows the errors that can be passed to a completion handler callback from any API which uses one:
ACPErrorUnexpected
- An unexpected error occurred.ACPErrorCallbackTimeout
- The timeout was met.ACPErrorCallbackNil
- The provided callback function is nil.ACPErrorExtensionNotInitialized
- The extension is not initialized.
Example
Objective-C
Copied to your clipboard[ACPCore getSdkIdentities:^(NSString * _Nullable content, NSError * _Nullable error) {if (error) {if (error.code == ACPErrorCallbackTimeout) {// handle timeout error} else if (error.code == ACPErrorCallbackNil) {// handle nil callback error} else if (error.code == ACPErrorExtensionNotInitialized) {// handle extension not initialized error} else if (error.code == ACPErrorUnexpected) {// handle unexpected error....} else {// use privacy status}}];
Swift
Copied to your clipboardACPCore.getPrivacyStatus { (privacyStatus, error) inif let error = error {let callbackError: NSError = (error as NSError)if (callbackError.code == ACPError.callbackTimeout.rawValue) {// handle timeout error} else if (callbackError.code == ACPError.callbackNil.rawValue) {// handle nil callback error} else if (callbackError.code == ACPError.extensionNotInitialized.rawValue) {// handle extension not initialized error} else if (callbackError.code == ACPError.unexpected.rawValue) {// handle unexpected error}} else {// use privacyStatus}}
Android
IAdobeCallback
This class provides the interface to receive results when the async APIs perform the requested action.
Copied to your clipboardpublic interface IAdobeCallback : IJavaObject, IDisposable, IJavaPeerable{void Call (Java.Lang.Object p0);}
IAdobeCallbackWithError
This class provides the interface to receive results or an error when the async APIs perform the requested action. When using this class, if the request cannot be completed within the default timeout or an unexpected error occurs, the request is aborted and the fail method is called with the corresponding AdobeError.
Copied to your clipboardpublic interface IAdobeCallbackWithError : IAdobeCallback, IJavaObject, IDisposable, IJavaPeerable{void Fail (AdobeError p0);}
AdobeError
Errors which may be passed to an AdobeCallbackWithError:
UnexpectedError
- An unexpected error occurred.CallbackTimeout
- The timeout was met.CallbackNull
- The provided callback function is null.ExtensionNotInitialized
- The extension is not initialized.
Example
Copied to your clipboardACPCore.GetPrivacyStatus(new AdobeCallbackWithError());class AdobeCallbackWithError : Java.Lang.Object, IAdobeCallbackWithError{public void Call(Java.Lang.Object stringContent){if (stringContent != null){Console.WriteLine("String callback content: " + stringContent);}else{Console.WriteLine("null content in string callback");}}public void Fail(AdobeError error){if (error == AdobeError.UnexpectedError){// handle unexpected error}else if (error == AdobeError.CallbackTimeout){// handle timeout error}else if (error == AdobeError.CallbackNull){// handle null callback error}else if (error == AdobeError.ExtensionNotInitialized){// handle extension not initialized error}
iOS
ACPError
Errors which may be passed to a completion handler callback from any API which uses one:
ACPError.Unexpected
- An unexpected error occurred.ACPError.CallbackTimeout
- The timeout was met.ACPError.CallbackNil
- The provided callback function is nil.ACPError.ExtensionNotInitialized
- The extension is not initialized.
Example
Copied to your clipboardACPCore.GetPrivacyStatusWithCompletionHandler((privacyStatus, error) => {if (error != null){if ( error.Code == (int)ACPError.CallbackTimeout){// handle timeout error}else if (error.Code == (int)ACPError.CallbackNil){// handle nil callback error}else if (error.Code == (int)ACPError.ExtensionNotInitialized){// handle extension not initialized error}else if (error.Code == (int)ACPError.Unexpected){// handle unexpected error}}else{Console.WriteLine("privacy status: " + privacyStatus);}});
Additional information
To learn what context data is, please read the documentation on context data.