Edit in GitHubLog an issue

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

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:)

Syntax

Copied to your clipboard
public static func collectLaunchInfo(_ userInfo: [String: Any])

Example

Copied to your clipboard
MobileCore.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:

Syntax

Copied to your clipboard
@objc(collectLaunchInfo:)
public static func collectLaunchInfo(_ userInfo: [String: Any])

Example

Copied to your clipboard
[AEPMobileCore collectLaunchInfo:launchOptions];

Java

Syntax

Copied to your clipboard
public static void collectPii(@NonNull final Map<String, String> data)

Example

Copied to your clipboard
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);

Swift

Syntax

Copied to your clipboard
public static func collectPii(_ data: [String: Any])

Example

Copied to your clipboard
MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);

Objective-C

Syntax

Copied to your clipboard
@objc(collectPii:)
public static func collectPii(_ data: [String: Any])

Example

Copied to your clipboard
[AEPMobileCore collectPii:data:@{@"key1" : @"value1",
@"key2" : @"value2"
}];

Java

Syntax

Copied to your clipboard
public static void dispatchEvent(@NonNull final Event event)

Example

Copied to your clipboard
final Map<String, Object> eventData = new HashMap<>();
eventData.put("sampleKey", "sampleValue");
final Event sampleEvent = new Event.Builder("SampleEventName", "SampleEventType", "SampleEventSource")
.setEventData(eventData)
.build();
MobileCore.dispatchEvent(sampleEvent);

Swift

Syntax

Copied to your clipboard
public static func dispatch(event: Event)

Example

Copied to your clipboard
let event = Event(name: "Sample Event Name", type: EventType.custom, source: EventType.custom, data: ["sampleKey": "sampleValue"])
MobileCore.dispatch(event: event)

Objective-C

Syntax

Copied to your clipboard
@objc(dispatch:)
public static func dispatch(event: Event)

Example

Copied to your clipboard
AEPEvent *event = [[AEPEvent alloc] initWithName:@"Sample Event Name" type:AEPEventType.custom source:AEPEventType.custom data:@{@"sampleKey": @"sampleValue"}];
[AEPMobileCore dispatch:event];

Java

Syntax

Copied to your clipboard
public static void dispatchEventWithResponseCallback(@NonNull final Event event, final long timeoutMS, @NonNull final AdobeCallbackWithError<Event> responseCallback)

Example

Copied to your clipboard
final Map<String, Object> eventData = new HashMap<>();
eventData.put("sampleKey", "sampleValue");
final Event sampleEvent = new Event.Builder("My Event", "SampleEventType", "SampleEventSource")
.setEventData(eventData)
.build();
MobileCore.dispatchEventWithResponseCallback(sampleEvent, 5000L, new AdobeCallbackWithError<Event>() {
// handle response event
});

Swift

Syntax

Copied to your clipboard
public static func dispatch(event: Event, timeout: TimeInterval = 1, responseCallback: @escaping (Event?) -> Void)

Example

Copied to your clipboard
let event = Event(name: "My Event", type: EventType.custom, source: EventType.custom, data: ["sampleKey": "sampleValue"])
MobileCore.dispatch(event: event) { (responseEvent) in
// handle responseEvent
}

Objective-C

Syntax

Copied to your clipboard
@objc(dispatch:timeout:responseCallback:)
public static func dispatch(event: Event, timeout: TimeInterval = 1, responseCallback: @escaping (Event?) -> Void)

Example

Copied to your clipboard
AEPEvent *event = [[AEPEvent alloc] initWithName:@"My Event" type:AEPEventType.custom source:AEPEventType.custom data:@{@"sampleKey": @"sampleValue"}];
[AEPMobileCore dispatch:event responseCallback:^(AEPEvent * _Nullable responseEvent) {
// handle responseEvent
}];

Java

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

Syntax

Copied to your clipboard
@Nullable
public static Application getApplication()

Example

Copied to your clipboard
Application app = MobileCore.getApplication();
if (app != null) {
...
}

Java

Syntax

Copied to your clipboard
@NonNull
public static LoggingMode getLogLevel()

Example

Copied to your clipboard
LoggingMode mode = MobileCore.getLogLevel();

The logLevel getter has been deprecated. To get the log level in the Swift AEP 3.x SDKs, please use Log.logFilter instead.

Swift

Syntax

Copied to your clipboard
public static var logFilter: LogLevel

This variable is part of the Log class within AEPServices.

Example

Copied to your clipboard
var logLevel = Log.logFilter

Objective-C

Syntax

Copied to your clipboard
@objc public static var logFilter: LogLevel

Example

Copied to your clipboard
AEPLogLevel logLevel = [AEPLog logFilter];

Java

Syntax

Copied to your clipboard
void getSdkIdentities(@NonNull 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

Copied to your clipboard
MobileCore.getSdkIdentities(new AdobeCallback<String>() {
@Override
public void call(String value) {
// handle the json string
}
});

Swift

Syntax

Copied to your clipboard
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

Copied to your clipboard
MobileCore.getSdkIdentities { (content, error) in
// handle completion
}

Objective-C

Syntax

Copied to your clipboard
@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

Copied to your clipboard
[AEPMobileCore getSdkIdentities:^(NSString * _Nullable content, NSError * _Nullable error) {
if (error) {
// handle error here
} else {
// handle the retrieved identities
}
}];

Java

Syntax

Copied to your clipboard
public static void initialize(
@NonNull final Application application,
@NonNull final String appId,
@Nullable final AdobeCallback<?> completionCallback)
  • application The Android Application instance.
  • appID The mobile property environment ID configured from the Data Collection UI.
  • completionCallback An Optional AdobeCallback triggered once initialization is complete.

Example

Copied to your clipboard
public class CoreApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.initialize(this, "ENVIRONMENT_ID", o -> {
Log.d(LOG_TAG, "AEP Mobile SDK is initialized");
});
}
}

Swift

Syntax

Copied to your clipboard
public static func initialize(appId: String, _ completion: (() -> Void)? = nil)
  • appId The mobile property environment ID configured from the Data Collection UI.
  • completion An Optional callback triggered once initialization is complete.

Example

Copied to your clipboard
// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MobileCore.initialize(appId: "ENVIRONMENT_ID") {
print("AEP Mobile SDK is initialized")
}
...
}

Objective-C

Syntax

Copied to your clipboard
@objc(initializeWithAppId:completion:)
public static func initialize(appId: String, _ completion: (() -> Void)? = nil)
  • appId The mobile property environment ID configured from the Data Collection UI.
  • completion An Optional callback triggered once initialization is complete.

Example

Copied to your clipboard
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AEPMobileCore initializeWithAppId:@"ENVIRONMENT_ID" completion:^{
NSLog(@"AEP Mobile SDK is initialized");
}];
...
}

Java

Syntax

Copied to your clipboard
public static void initialize(
@NonNull final Application application,
@NonNull final InitOptions initOptions,
@Nullable final AdobeCallback<?> completionCallback)
  • application The Android Application instance.
  • initOptions The InitOptions to configure the SDK.
  • completionCallback An Optional AdobeCallback triggered once initialization is complete.

Example

Copied to your clipboard
public class CoreApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// Use InitOptions to disable automatic lifecycle tracking.
InitOptions initOptions = InitOptions.configureWithAppID("ENVIRONMENT_ID")
initOptions.lifecycleAutomaticTrackingEnabled = false
MobileCore.initialize(this, initOptions, o -> {
Log.d(LOG_TAG, "AEP Mobile SDK is initialized");
});
}
}

Swift

Syntax

Copied to your clipboard
public static func initialize(options: InitOptions, _ completion: (() -> Void)? = nil)
  • options The InitOptions to configure the SDK.
  • completion An Optional callback triggered once initialization is complete.

Example

Copied to your clipboard
// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Use InitOptions to disable automatic lifecycle tracking.
let options = InitOptions(appId: "ENVIRONMENT_ID")
options.lifecycleAutomaticTrackingEnabled = false
MobileCore.initialize(options: options) {
print("AEP Mobile SDK is initialized")
}
...
}

Objective-C

Syntax

Copied to your clipboard
@objc(initializeWithOptions:completion:)
public static func initialize(options: InitOptions, _ completion: (() -> Void)? = nil)
  • options The InitOptions to configure the SDK.
  • completion An Optional callback triggered once initialization is complete.

Example

Copied to your clipboard
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Use InitOptions to disable automatic lifecycle tracking.
AEPInitOptions *options = [[AEPInitOptions alloc] initWithAppId:@"ENVIRONMENT_ID"];
options.lifecycleAutomaticTrackingEnabled = NO;
[AEPMobileCore initializeWithOptions:options completion:^{
NSLog(@"AEP Mobile SDK is initialized");
}];
...
}

This API was deprecated in v2.0.0 of the Mobile Core extension. Use the com.adobe.marketing.mobile.services.Log instead.

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

Syntax

Copied to your clipboard
public static void log(final LoggingMode mode, final String tag, final String message)

Example

Copied to your clipboard
MobileCore.log(LoggingMode.DEBUG, "MyClassName", "Provided data was null");

Output

Copied to your clipboard
D/AdobeExperienceSDK: MyClassName - Provided data was null

Swift

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 AEP SDK. For example, if logging an error message using Log.error(label:_ message:_), the printed output looks like [AEP SDK ERROR <label>]: message.

Syntax

Copied to your clipboard
public static func trace(label: String, _ message: String) {
public static func debug(label: String, _ message: String)
public static func warning(label: String, _ message: String) {
public static func error(label: String, _ message: String) {

Example

Copied to your clipboard
Log.trace(label: "testLabel", "Test message")
Log.debug(label: "testLabel", "Test message")
Log.warning(label: "testLabel", "Test message")
Log.error(label: "testLabel", "Test message")

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 AEP SDK. For example, if logging an error message using [AEPLog errorWithLabel: _ message:_], the printed output looks like [AEP SDK ERROR <label>]: message.

Syntax

Copied to your clipboard
@objc(traceWithLabel:message:)
public static func trace(label: String, _ message: String)
@objc(debugWithLabel:message:)
public static func debug(label: String, _ message: String)
@objc(warningWithLabel:message:)
public static func warning(label: String, _ message: String)
@objc(errorWithLabel:message:)
public static func error(label: String, _ message: String)

Example

Copied to your clipboard
[AEPLog traceWithLabel:@"testLabel" message:@"testMessage"];
[AEPLog debugWithLabel:@"testLabel" message:@"testMessage"];
[AEPLog warningWithLabel:@"testLabel" message:@"testMessage"];
[AEPLog errorWithLabel:@"testLabel" message:@"testMessage"];

Java

Syntax

Copied to your clipboard
public static void registerEventListener(@NonNull final String eventType, @NonNull final String eventSource, @NonNull final AdobeCallback<Event> callback)

Example

Copied to your clipboard
MobileCore.registerEventListener(EventType.CONFIGURATION, EventSource.RESPONSE_CONTENT, new AdobeCallback<Event>() {
@Override
public void call(Event value) {
// handle event
}
});

Swift

Syntax

Copied to your clipboard
public static func registerEventListener(type: String, source: String, listener: @escaping EventListener)

Example

Copied to your clipboard
MobileCore.registerEventListener(type: EventType.configuration, source: EventSource.responseContent, listener: { event in
// handle event
})

Objective-C

Syntax

Copied to your clipboard
@objc(registerEventListenerWithType:source:listener:)
public static func registerEventListener(type: String, source: String, listener: @escaping EventListener)

Example

Copied to your clipboard
[AEPMobileCore registerEventListenerWithType: type source: source listener:^(AEPEvent * _Nonnull event) {
// handle event
}];

Java

Syntax

Copied to your clipboard
public static boolean registerExtension(@NonNull final Class<? extends Extension> extensionClass, @Nullable final ExtensionErrorCallback<ExtensionError> errorCallback)

Example

Copied to your clipboard
MobileCore.registerExtension(Signal.EXTENSION, errorCallback -> {
// handle callback
});

Swift

Syntax

Copied to your clipboard
public static func registerExtension(_ exten: Extension.Type, _ completion: (() -> Void)? = nil)

Example

Copied to your clipboard
MobileCore.registerExtension(Lifecycle.self) {
// handle completion
}

Objective-C

Syntax

Copied to your clipboard
@objc(registerExtension:completion:)
public static func registerExtension(_ exten: Extension.Type, _ completion: (() -> Void)? = nil)

Example

Copied to your clipboard
[AEPMobileCore registerExtension:AEPMobileLifecycle.class completion:^{
// handle completion
}];

Java

Syntax

Copied to your clipboard
public static void registerExtensions(@NonNull final List<Class<? extends Extension>> extensions, @Nullable final AdobeCallback<?> completionCallback)

Example

Copied to your clipboard
import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.edge.consent.Consent;
import com.adobe.marketing.mobile.edge.identity.Identity;
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 {
// Set up the preferred Environment File ID from your mobile property configured in Data Collection UI
private static final String ENVIRONMENT_FILE_ID = "YOUR_ENVIRONMENT_FILE_ID";
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID);
List<Class<? extends Extension>> extensions = Arrays.asList(
Lifecycle.EXTENSION,
Signal.EXTENSION,
UserProfile.EXTENSION
Edge.EXTENSION,
Consent.EXTENSION,
EdgeIdentity.EXTENSION);
MobileCore.registerExtensions(extensions, o -> {
Log.d(LOG_TAG, "AEP Mobile SDK is initialized");
});
}
}

Swift

Syntax

Copied to your clipboard
public static func registerExtensions(_ extensions: [NSObject.Type], _ completion: (() -> Void)? = nil)

Example

Copied to your clipboard
// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MobileCore.registerExtensions([Signal.self, Lifecycle.self, UserProfile.self, Edge.self, AEPEdgeIdentity.Identity.self, Consent.self], {
MobileCore.configureWith(appId: "yourAppId")
})
...
}

Objective-C

Syntax

Copied to your clipboard
@objc(registerExtensions:completion:)
public static func registerExtensions(_ extensions: [NSObject.Type], _ completion: (() -> Void)? = nil)

Example

Copied to your clipboard
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AEPMobileCore registerExtensions:@[AEPMobileSignal.class, AEPMobileLifecycle.class, AEPMobileUserProfile.class, AEPMobileEdge.class, AEPMobileEdgeIdentity.class, AEPMobileEdgeConsent.class] completion:^{
[AEPMobileCore configureWithAppId: @"yourAppId"];
}];
...
}

Java

Syntax

Copied to your clipboard
void resetIdentities();

Example

Copied to your clipboard
MobileCore.resetIdentities();

Swift

Syntax

Copied to your clipboard
static func resetIdentities()

Example

Copied to your clipboard
MobileCore.resetIdentities()

Objective-C

Syntax

Copied to your clipboard
@objc(resetIdentities)
static func resetIdentities()

Example

Copied to your clipboard
[AEPMobileCore resetIdentities];

Swift

Syntax

Copied to your clipboard
public static func setAppGroup(_ group: String?)

Example

Copied to your clipboard
MobileCore.setAppGroup("appGroupId")

Objective-C

Syntax

Copied to your clipboard
@objc(setAppGroup:)
public static func setAppGroup(_ group: String?)

Example

Copied to your clipboard
[AEPMobileCore setAppGroup:@"app-group-id"];

Java

Syntax

Copied to your clipboard
public static void setApplication(@NonNull final Application app)

Example

Copied to your clipboard
public class CoreApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
List<Class<? extends Extension>> extensions = Arrays.asList(
Lifecycle.EXTENSION, Signal.EXTENSION, UserProfile.EXTENSION...);
MobileCore.registerExtensions(extensions, o -> {
Log.d(LOG_TAG, "AEP Mobile SDK is initialized");
});
}
}

Java

Syntax

Copied to your clipboard
public static void setLogLevel(@NonNull LoggingMode mode)

Example

Copied to your clipboard
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
MobileCore.setLogLevel(LoggingMode.VERBOSE);

Swift

Syntax

Copied to your clipboard
public static func setLogLevel(_ level: LogLevel)

Example

Copied to your clipboard
import AEPCore
import AEPServices
MobileCore.setLogLevel(.trace)

Objective-C

Syntax

Copied to your clipboard
@objc(setLogLevel:)
public static func setLogLevel(_ level: LogLevel)

Example

Copied to your clipboard
@import AEPCore;
@import AEPServices;
[AEPMobileCore setLogLevel: AEPLogLevelTrace];

Java

Syntax

Copied to your clipboard
public static void setPushIdentifier(@Nullable 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 SDK
MobileCore.setPushIdentifier(token);

Swift

Syntax

Copied to your clipboard
public static func setPushIdentifier(_ deviceToken: Data?)

Example

Copied to your clipboard
MobileCore.setPushIdentifier(deviceToken)

Objective-C

Syntax

Copied to your clipboard
@objc(setPushIdentifier:)
public static func setPushIdentifier(_ deviceToken: Data?)

Example

Copied to your clipboard
[AEPMobileCore setPushIdentifier:deviceToken];

Java

setSmallIconResourceID

Syntax

Copied to your clipboard
public static void setSmallIconResourceID(int resourceID)

Example

Copied to your clipboard
MobileCore.setSmallIconResourceID(R.mipmap.ic_launcher_round);

setLargeIconResourceID

Syntax

Copied to your clipboard
public static void setLargeIconResourceID(int resourceID)

Example

Copied to your clipboard
MobileCore.setLargeIconResourceID(R.mipmap.ic_launcher_round);

The wrapper type can be set to one of the follwing types: NONE, REACT_NATIVE, FLUTTER, CORDOVA, UNITY, XAMARIN.

Java

Syntax

Copied to your clipboard
public static void setWrapperType(@NonNull final WrapperType wrapperType)

Example

Copied to your clipboard
MobileCore.setWrapperType(WrapperType.REACT_NATIVE);

The wrapper type can be set to one of the follwing types: none, reactNative, flutter, cordova, unity, xamarin.

Swift

Syntax

Copied to your clipboard
public static func setWrapperType(_ type: WrapperType)

Example

Copied to your clipboard
MobileCore.setWrapperType(.flutter)

Objective-C

Syntax

Copied to your clipboard
@objc(setWrapperType:)
public static func setWrapperType(_ type: WrapperType)

Example

Copied to your clipboard
[AEPMobileCore setWrapperType:AEPWrapperTypeFlutter];

Java

Syntax

Copied to your clipboard
public static void start(@Nullable final AdobeCallback<?> completionCallback)

Example

Copied to your clipboard
import com.adobe.marketing.mobile.AdobeCallback;
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 MyApp extends Application {
...
@Override
public void onCreate(){
super.onCreate();
MobileCore.setApplication(this);
UserProfile.registerExtension();
Lifecycle.registerExtension();
Signal.registerExtension();
MobileCore.start(new AdobeCallback () {
@Override
public void call(Object o) {
// implement callback
}
});
}
}

Java

Syntax

Copied to your clipboard
public static void trackAction(@NonNull final String action, @Nullable 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 clipboard
Map<String, String> additionalContextData = new HashMap<String, String>();
additionalContextData.put("customKey", "value");
MobileCore.trackAction("loginClicked", additionalContextData);

Swift

Syntax

Copied to your clipboard
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

Copied to your clipboard
MobileCore.track(action: "action name", data: ["key": "value"])

Objective-C

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

Example

Copied to your clipboard
[AEPMobileCore trackAction:@"action name" data:@{@"key":@"value"}];

Java

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

Syntax

Copied to your clipboard
public static void trackState(@NonNull final String state, @Nullable 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 clipboard
Map<String, String> additionalContextData = new HashMap<String, String>();
additionalContextData.put("customKey", "value");
MobileCore.trackState("homePage", additionalContextData);

Swift

Syntax

Copied to your clipboard
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

Copied to your clipboard
MobileCore.track(state: "state name", data: ["key": "value"])

Objective-C

Syntax

Copied to your clipboard
@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

Copied to your clipboard
[AEPMobileCore trackState:@"state name" data:@{@"key":@"value"}];

Java

Copied to your clipboard
public interface AdobeCallback<T> {
void call(final T value);
}

Swift

Example

Copied to your clipboard
MobileCore.getSdkIdentities { (content, error) in
if let error = error, let aepError = error as? AEPError {
switch aepError {
case .unexpected:
// Handle unexpected error
case .callbackTimeout:
// Handle callback timeout error
case .callbackNil:
// Handle callback being nil error
case .none:
// no error
case .serverError:
// handle server error
case .networkError:
// handle network error
case .invalidRequest:
// handle invalid request error
case .invalidResponse:
// handle invalid response error
case .errorExtensionNotInitialized:
// handle extension not initialized error
@unknown default:
// handle unknown error
}
}
...
}

Objective-C

Example

Copied to your clipboard
[AEPMobileCore getSdkIdentities:^(NSString * _Nullable content, NSError * _Nullable error) {
if (error) {
if (error.code == AEPErrorUnexpected) {
// Handle unexpected error
} else if (error.code == AEPErrorCallbackTimeout) {
// Handle callback timeout error
} else if (error.code == AEPErrorCallbackNil) {
// Handle callback being nil error
} else if (error.code == AEPErrorNone) {
// no error
} else if (error.code == AEPErrorServerError) {
// handle server error
} else if (error.code == AEPErrorNetworkError) {
// handle network error
} else if (error.code == AEPErrorInvalidRequest) {
// handle invalid request error
} else if (error.code == AEPErrorInvalidResponse) {
// handle invalid response error
} else if (error.code == AEPErrorErrorExtensionNotInitialized) {
// handle extension not intialized error
}
}
...
}];

Java

Syntax

Copied to your clipboard
public interface AdobeCallbackWithError<T> extends AdobeCallback<T> {
void fail(final AdobeError error);
}

Example

Copied to your clipboard
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
} else if (error == AdobeError.SERVER_ERROR) {
// handle server error
} else if (error == AdobeError.NETWORK_ERROR) {
// handle network error
} else if (error == AdobeError.INVALID_REQUEST) {
// handle invalid request error
} else if (error == AdobeError.INVALID_RESPONSE) {
// handle invalid response error
}
}
@Override
public void call(final MobilePrivacyStatus value) {
// use MobilePrivacyStatus value
}
});
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.