Mobile Core API reference

Application reference (Android only)

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.

Set the Application instance

You can use the setApplication method to pass the Android Application instance to Mobile SDK.

Android
Xamarin
Android

Java

setApplication

Syntax

public static void setApplication(final Application app)

Example

public class CoreApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
MobileCore.start(null);
}
}
Xamarin

C#

setApplication

Example

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
ACPCore.Application = this.Application;
ACPCore.Start(null);
}
}

Get the Application instance

You can use the getApplication method to get the previously set Android Application instance. The Application instance is mainly provided for third-party extensions.

Android
Xamarin
Android

Java

getApplication

MobileCore.getApplication will return null if the Application object was destroyed or if MobileCore.setApplication was not previously called.

Syntax

public static Application getApplication()

Example

Application app = MobileCore.getApplication();
if (app != null) {
...
}
Xamarin

C#

getApplication

ACPCore.Application may be null if the Application object was destroyed or was not set in the Core.

Example

var app = ACPCore.Application;
if (app != null) {
...
}

Track app actions

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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Unity
Cordova
Xamarin
Android

Java

trackAction

Syntax

public 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

Map<String, String> additionalContextData = new HashMap<String, String>();
additionalContextData.put("customKey", "value");
MobileCore.trackAction("loginClicked", additionalContextData);
iOS (AEP 3.x)

Swift

trackAction

Syntax

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 this hit.

Example

MobileCore.track(action: "action name", data: ["key": "value"])

Objective-C

trackAction

Syntax

@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 this hit.

Example

[AEPMobileCore trackAction:@"action name" data:@{@"key":@"value"}];
iOS (ACP 2.x)

Objective-C

trackAction

Syntax

+ (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

[ACPCore trackAction:@"action name" data:@{@"key":@"value"}];

Swift

trackAction

Syntax

@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

ACPCore.track(action: "action name", data: ["key": "value"])
React Native

Javascript

trackAction

Syntax

trackAction(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

ACPCore.trackAction("action name", {"key": "value"});
Flutter

Dart

trackAction

Syntax

Future<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

FlutterACPCore.trackAction("action name", data: {"key": "value"});
Unity

C#

trackAction

Syntax

public 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

var contextData = new Dictionary<string, string>();
contextData.Add("key", "value");
ACPCore.TrackAction("action", contextData);
Cordova

Cordova

trackAction

Syntax

ACPCore.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

ACPCore.trackAction("cordovaAction", {"cordovaKey":"cordovaValue"}, successCallback, errorCallback);
Xamarin

C#

trackAction

iOS Syntax

public 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

public 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.

Example

iOS

var data = new NSMutableDictionary<NSString, NSString>
{
["key"] = new NSString("value")
};
ACPCore.TrackAction("action", data);

Android

var data = new Dictionary<string, string>();
data.Add("key", "value");
ACPCore.TrackAction("action", data);

Track application states and views

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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
Android

Java

In Android, trackState is typically called every time a new Activity is loaded.

trackState

Syntax

public 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

Map<String, String> additionalContextData = new HashMap<String, String>();
additionalContextData.put("customKey", "value");
MobileCore.trackState("homePage", additionalContextData);
iOS (AEP 3.x)

Swift

trackState

Syntax

static func track(state: String?, data: [String: Any]?)
  • state contains the name of the state to track.

  • contextData contains the context data to attach on this hit.

Example

MobileCore.track(state: "state name", data: ["key": "value"])

Objective-C

trackState

Syntax

@objc(trackState:data:)
static func track(state: String?, data: [String: Any]?)
  • state contains the name of the state to track.

  • contextData contains the context data to attach on this hit.

Example

[AEPMobileCore trackState:@"state name" data:@{@"key":@"value"}];
iOS (ACP 2.x)

Objective-C

trackState

Syntax

(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

[ACPCore trackState:@"state name" data:@{@"key":@"value"}];

Swift

trackState

Syntax

+ (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

ACPCore.trackState("state name", data: ["key": "value"])
React Native

Javascript

trackState

Syntax

trackState(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

ACPCore.trackState("state name", {"key": "value"});
Flutter

Dart

trackState

Syntax

Future<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

FlutterACPCore.trackState("state name", data: {"key1: "value"})
Cordova

Cordova

trackState

Syntax

ACPCore.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

ACPCore.trackState("cordovaState", {"cordovaKey":"cordovaValue"}, successCallback, errorCallback);
Unity

C#

trackState

Syntax

public 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

var dict = new Dictionary<string, string>();
dict.Add("key", "value");
ACPCore.TrackState("state", dict);
Xamarin

C#

trackState

iOS syntax

public 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

public 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

var data = new NSMutableDictionary<NSString, NSString>
{
["key"] = new NSString("value")
};
ACPCore.TrackState("state", data);

Android example

var data = new Dictionary<string, string>();
data.Add("key", "value");
ACPCore.TrackState("state", data);

Set the advertising ID

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.

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.

It is recommended to 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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
Android

Java

setPushIdentifier

Syntax

public static void setPushIdentifier(final String pushIdentifier);
  • pushIdentifier is a string that contains the device token for push notifications.

Example

//Retrieve the token from either GCM or FCM, and pass it to the SDK
MobileCore.setPushIdentifier(token);
iOS (AEP 3.x)

Swift

setPushIdentifier

Syntax

public static func setPushIdentifier(_ deviceToken: Data?)

Example

MobileCore.setPushIdentifier(deviceToken)

Objective-C

setPushIdentifier

Syntax

@objc(setPushIdentifier:)
public static func setPushIdentifier(_ deviceToken: Data?)

Example

[AEPMobileCore setPushIdentifier:deviceToken];
iOS (ACP 2.x)

Objective-C

setPushIdentifier

Syntax

public static func setPushIdentifier(_ deviceToken: Data?)
  • deviceToken is a string that contains the device token for push notifications.

Example

// Set the deviceToken that the APNS has assigned to the device
[ACPCore setPushIdentifier:deviceToken];

Swift

setPushIdentifier

Syntax

@objc(setPushIdentifier:)
public static func setPushIdentifier(_ deviceToken: Data?)
  • deviceToken is a string that contains the device token for push notifications.

Example

// Set the deviceToken that the APNs has assigned to the device
MobileCore.setPushIdentifier(deviceToken)

Collect personally identifiable information

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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

Java

collectPii

Syntax

public static void collectPII(final Map<String, String> piiData);

Example

Map<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 send
MobileCore.collectPII(data);
iOS (AEP 3.x)

Swift

collectPii

Syntax

public static func collectPii(_ data: [String: Any])

Example

MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);

Objective-C

collectPii

Syntax

@objc(collectPii:)
public static func collectPii(_ data: [String: Any])

Example

[AEPMobileCore collectPii:data:@{@"key1" : @"value1",
@"key2" : @"value2"
}];
iOS (ACP 2.x)

Objective-C

collectPii

Syntax

(void) collectPii: (nonnull NSDictionary<NSString*, NSString*>*) data;

Example

[ACPCore collectPii:data:@{@"key1" : "@value1",
@"key2" : "@value2"
}];

Swift

collectPii

Syntax

ACPCore.collectPii(data: [String : String])

Example

MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
React Native

Javascript

collectPii

Syntax

ACPCore.collectPii(data: [String : String])

Example

ACPCore.collectPii({"myPii": "data"});

Swift

collectPii

Syntax

ACPCore.collectPii(data: [String : String])

Example

MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);

Collect launch information

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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
Android

The Android SDK automatically registers an Application.ActivityLifecycleCallbacksand 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

iOS (AEP 3.x)

Swift

This method should be called to support the following use cases:

  • Tracking deep link clickthroughs

    • From application(_:didFinishLaunchingWithOptions:)

    • Extract userInfo from url: UIApplication.LaunchOptionsKey

  • Tracking push message clickthrough

    • From application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

collectLaunchInfo

Syntax

public static func collectLaunchInfo(_ userInfo: [String: Any])

Example

AEPCore.collectLaunchInfo(userInfo)

Objective-C

This method should be called to support the following use cases:

  • Tracking deep link clickthroughs

    • From application:didFinishLaunchingWithOptions

    • Extract userInfo from UIApplicationLaunchOptionsURLKey

      • Tracking push message clickthrough

    • From application:didReceiveRemoteNotification:fetchCompletionHandler:

collectLaunchInfo

Syntax

@objc(collectLaunchInfo:)
public static func collectLaunchInfo(_ userInfo: [String: Any])

Example

[AEPMobileCore collectLaunchInfo:launchOptions];
iOS (ACP 2.x)

Objective-C

The collectLaunchInfo method should be used in the following use cases:

  • Tracking a deep link clickthrough

    • From application:didFinishLaunchingWithOptions

    • Extract userInfo from UIApplicationLaunchOptionsURLKey

  • Tracking a push message clickthrough

    • From application:didReceiveRemoteNotification:fetchCompletionHandler:

collectLaunchInfo

Syntax

(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;

Example

[ACPCore collectLaunchInfo:launchOptions];

Swift

The collectLaunchInfo method should be used in the following use cases:

  • Tracking a deep link clickthrough

    • From application(_:didFinishLaunchingWithOptions:)

    • Extract userInfo from url: UIApplication.LaunchOptionsKey

  • Tracking a push message clickthrough

    • From application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

collectLaunchInfo

Syntax

(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;

Example

AEPCore.collectLaunchInfo(userInfo)

Retrieving stored identifiers

The following SDK identities, as applicable, 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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
Android

Java

getSdkIdentities

Syntax

void 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, the fail method is called with the appropriate AdobeError.

Example

MobileCore.getSdkIdentities(new AdobeCallback<String>() {
@Override
public void call(String value) {
// handle the json string
}
});
iOS (AEP 3.x)

Swift

MobileCore.getSdkIdentities { (content, error) in
// handle completion
}

Objective-C

getSdkIdentities

Syntax

@objc(getSdkIdentities:)
static func getSdkIdentities(completion: @escaping (String?, Error?) -> Void)
  • 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

Objective-C

[AEPMobileCore getSdkIdentities:^(NSString * _Nullable content, NSError * _Nullable error) {
if (error) {
// handle error here
} else {
// handle the retrieved identities
}
}];
iOS (ACP 2.x)

Objective-C

getSdkIdentities

Syntax

(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

[ACPCore getSdkIdentities:^(NSString * _Nullable content){
NSLog(content);
[ACPCore getSdkIdentitiesWithCompletionHandler:^(NSString * _Nullable content, NSError * _Nullable error) {
if (error) {
// handle error here
} else {
// handle the retrieved identities
NSLog(content);
}
}];

Swift

MobileCore.getSdkIdentities { (content, error) in
// handle completion
}

Reset identities

The resetIdentities method requests that each extension resets the identities it owns. Each extension responds to this request uniquely.

This API is only handled by the Edge and Edge Identity extensions. Calling resetIdentities does not clear identities in non-edge extensions, such as Identity.

Android
iOS (ACP 2.x)
Android

Java

resetIdentities

Note, this method is only available in Mobile Core v.1.8.0 and above.

Syntax

void resetIdentities();

Example

MobileCore.resetIdentities();
iOS (ACP 2.x)

Objective-C

Note, this method is only available in Mobile Core v.1.8.0 and above.

resetIdentities

Syntax

@objc(resetIdentities)
static func resetIdentities()

Example

[ACPCore resetIdentities];

Swift

Note, this method is only available in Mobile Core v.1.8.0 and above.

resetIdentities

Syntax

static func resetIdentities()

Example

MobileCore.resetIdentities()

since AEPCore v3.1.0

Set icons for local notification (Android only)

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.

The following methods are only available in Android and Xamarin Android.

Android
Xamarin
Android

Java

setSmallIconResourceID

Syntax

public static void setSmallIconResourceID(int resourceID)

Example

MobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);

setLargeIconResourceID

Syntax

public static void setLargeIconResourceID(int resourceID)

Example

MobileCore.setLargeIconResourceID(R.mipmap.ic_launcher_round);
Xamarin

C#

setSmallIconResourceID

Syntax

public unsafe static void SetSmallIconResourceID (int resourceID);

Example

ACPCore.SetSmallIconResourceID(Resource.Mipmap.icon_round);

setLargeIconResourceID

Syntax

public unsafe static void SetLargeIconResourceID (int resourceID);

Example

ACPCore.SetLargeIconResourceID(Resource.Mipmap.icon_round);

Logging

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

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.erroron 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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
Android

Java

setLogLevel

Syntax

public static void setLogLevel(LoggingMode mode)

Example

import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
MobileCore.setLogLevel(LoggingMode.VERBOSE);
iOS (AEP 3.x)

Swift

setLogLevel

Syntax

public static func setLogLevel(_ level: LogLevel)

Example

MobileCore.setLogLevel(.trace)

Objective C

setLogLevel

Syntax

@objc(setLogLevel:)
public static func setLogLevel(_ level: LogLevel)

Example

[AEPMobileCore setLogLevel: AEPLogLevelTrace];
iOS (ACP 2.x)

Objective-C

setLogLevel

Syntax

(void) setLogLevel: (ACPMobileLogLevel) logLevel;

Example

#import "ACPCore.h"
[ACPCore setLogLevel: AEPLogLevelTrace];

Swift

setLogLevel

Syntax

(void) setLogLevel: (ACPMobileLogLevel) logLevel;

Example

import ACPCore
ACPCore.setLogLevel(ACPMobileLogLevel.verbose);
React Native

Javascript

setLogLevel

Syntax

(void) setLogLevel: (ACPMobileLogLevel) logLevel;

Example

import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';
ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
Flutter

Dart

setLogLevel

Syntax

(void) setLogLevel: (ACPMobileLogLevel) logLevel;

Example

import 'package:flutter_acpcore/src/acpmobile_logging_level.dart';
FlutterACPCore.setLogLevel(ACPLoggingLevel.VERBOSE);
Cordova

Cordova

From least to most verbose, the order of Mobile SDK logging modes is as follows:

  • ACPCore.ACPMobileLogLevelError

  • ACPCore.ACPMobileLogLevelWarning

  • ACPCore.ACPMobileLogLevelDebug

  • ACPCore.ACPMobileLogLevelVerbose

setLogLevel

Syntax

ACPCore.setLogLevel = function(logLevel, success, fail);

Example

ACPCore.setLogLevel(ACPCore.ACPMobileLogLevelVerbose, successCallback, errorCallback);
MobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);
Unity

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

setLogLevel

Syntax

public static void SetLogLevel(ACPMobileLogLevel logLevel)

Example

ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.ERROR);
Xamarin

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;

setLogLevel

iOS syntax

public static ACPMobileLogLevel LogLevel { get, set }

Android syntax

public unsafe static LoggingMode LogLevel { get, set }

iOS example

ACPCore.LogLevel = ACPMobileLogLevel.Verbose;

Android example

ACPCore.LogLevel = LoggingMode.Verbose;
Android
iOS (ACP 2.x)
React Native
Unity
Xamarin
Android

Java

getLogLevel

Syntax

public static LoggingMode getLogLevel()

Example

LoggingMode mode = MobileCore.getLogLevel();
iOS (ACP 2.x)

Objective-C

getLogLevel

Syntax

(ACPMobileLogLevel) logLevel;

Example

var logLevel:ACPMobileLogLevel = [ACPCore logLevel];

Swift

getLogLevel

Syntax

(ACPMobileLogLevel) logLevel;

Example

let logLevel:ACPMobileLogLevel = ACPCore.logLevel();
React Native

Javascript

getLogLevel

Example

ACPCore.getLogLevel().then(level => console.log("AdobeExperienceSDK: Log Level = " + level));
Unity

C#

getLogLevel

Example

ACPCore.ACPMobileLogLevel logLevel = ACPCore.GetLogLevel();
Xamarin

C#

getLogLevel

Example

var logLevel = ACPCore.LogLevel;
Android
iOS (ACP 2.x)
React Native
Xamarin
Android

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 uses android.util.Log.v

  • LoggingMode.DEBUG uses android.util.Log.d

  • LoggingMode.WARNING uses android.util.Log.w

  • LoggingMode.ERROR uses android.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).

log

Syntax

public static void log(final LoggingMode mode, final String tag, final String message)

Example

MobileCore.log(LoggingMode.DEBUG, "MyClassName", "Provided data was null");

Output

D/AdobeExperienceSDK: MyClassName - Provided data was null
iOS (ACP 2.x)

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.

log

Syntax

+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;

Example

[ACPCore log: ACPMobileLogLevelDebug, tag:@"MyClassName", message:@"Provided data was nil"];

Output example

[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil

Swift

log

Syntax

+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;

Example

ACPCore.log(ACPMobileLogLevel.debug, tag: "MyClassName", message: "Provided data was nil");

Output example

[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
React Native

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

ACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");

Note: ACPMobileLogLevel contains the following getters:

const ERROR = "ACP_LOG_LEVEL_ERROR";
const WARNING = "ACP_LOG_LEVEL_WARNING";
const DEBUG = "ACP_LOG_LEVEL_DEBUG";
const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";
Xamarin

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

ACPCore.Log(ACPMobileLogLevel.Error, "xamarin tag", "xamarin message");
[AdobeExperienceSDK ERROR <xamarin tag>]: xamarin message

Android syntax

ACPCore.Log(LoggingMode.Error, "xamarin tag", "xamarin message");
[AdobeExperienceSDK] xamarin tag - xamarin message

Handle open URL action

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.

iOS (ACP 2.x)
iOS (ACP 2.x)

Objective C

registerURLHandler

Syntax

+ (void) registerURLHandler: (nonnull BOOL (^) (NSString* __nullable url)) callback;

Example

[ACPCore registerURLHandler:^BOOL(NSString * _Nullable url) {
...
}];

Set app group (iOS only)

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.

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.

iOS (ACP 2.x)
Xamarin
iOS (ACP 2.x)

Objective-C

setAppGroup

Syntax

public static func setAppGroup(_ group: String?)

Example

[ACPCore setAppGroup:@"app-group-id"];

Swift

setAppGroup

Syntax

public static func setAppGroup(_ group: String?)

Example

ACPCore.setAppGroup("app-group-id")
Xamarin

C#

setAppGroup

Syntax

public static void SetAppGroup (string appGroup);

Example

ACPCore.SetAppGroup("app_group");

Public classes

Android
iOS (ACP 2.x)
Xamarin
Android

Java

AdobeCallback

The AdobeCallback class provides the interface to receive results when the asynchronous APIs perform the requested action.

public 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.

public 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

MobileCore.getPrivacyStatus(new AdobeCallbackWithError<MobilePrivacyStatus>() {
@Override
public 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
}
}
@Override
public void call(final MobilePrivacyStatus value) {
// use MobilePrivacyStatus value
}
});
iOS (ACP 2.x)

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.

Examples

Objective-C

[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

ACPCore.getPrivacyStatus { (privacyStatus, error) in
if 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
}
}
Xamarin

Android

IAdobeCallback

This class provides the interface to receive results when the async APIs perform the requested action.

public 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.

public 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.