Edit in GitHubLog an issue

Mobile Core API reference

clearUpdatedConfiguration

Programmatic updates made to the configuration can be cleared via the clearUpdatedConfiguration API. For more information about configuration in Mobile Core, please refer to the Configuration API reference.

collectMessageInfo

User interactions with local or push notifications can be tracked by invoking the collectMessageInfo API. Please refer to this page for more information about tracking local and push notification message interactions.

collectLaunchInfo

You can provide the user information to the SDK from various launch points in your application.

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

collectPii

The collectPii method lets the SDK to collect sensitive or personally identifiable information (PII).

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

configureWithAppId

The configureWithAppId API can be used to download the configuration for the provided app ID and apply the configuration to the current session. For more information about configuration in Mobile Core, please refer to the Configuration API reference.

configureWithFileInAssets

You can bundle a JSON configuration file in the app's assets folder and use configureWithFileInAssets API to replace or complement the configuration that was downloaded using the configureWithAppId API. For more information about configuration in Mobile Core, please refer to the Configuration API reference.

configureWithFileInPath

You can bundle a JSON configuration file in you app package and use configureWithFileInPath API to replace or complement the configuration that was downloaded using the configureWithAppId API. For more information about configuration in Mobile Core, please refer to the Configuration API reference.

dispatch / dispatchEvent

This method can be used to send an event through the Mobile Core for other extensions to consume.

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

dispatch / dispatchEventWithResponseCallback

This method can be used to send an event through the Mobile Core for other extensions to consume. The provided event is used as a trigger and in return a response event is provided as a callback. The callback is invoked with a null event if the response could not be provided within the given timeout.

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
});

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 clipboard
@Nullable
public static Application getApplication()

Example

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

getLogLevel

This API gets the current log level being used in the SDK.

Java

Syntax

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

Example

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

getPrivacyStatus

You can use the getPrivacyStatus API to retrieve the current privacy status. For more information about privacy in Mobile Core, please see Privacy and GDPR

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.

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
}
});

log

This is the API used to log from the SDK.

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

registerEventListener

An EventListener can be registered with MobileCore to be notified when Events matching a type and source are dispatched.

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
}
});

registerExtension

Extensions can be incrementally registered with Mobile Core using the registerExtension API.

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
});

registerExtensions

Extensions are registered with Mobile Core so that they can dispatch and listen for events. This API can be used to register desired extensions and boot up the SDK for event processing. Calling MobileCore.start() API is deprecated starting Mobile Core v2.0.0 and is no longer required when using MobileCore.registerExtensions().

The following code snippets demonstrate how Lifecycle, Signal, Profile, Edge, and other extensions are imported and registered.

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");
});
}
}

resetIdentities

The resetIdentities method requests that each extension resets the identities it owns and each extension responds to this request uniquely. For more details, check the resetIdentities API reference on each of the extensions you use.

Java

Syntax

Copied to your clipboard
void resetIdentities();

Example

Copied to your clipboard
MobileCore.resetIdentities();

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.

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"];

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.

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.

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");
});
}
}

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

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

setPrivacyStatus

You can use the setPrivacyStatus API to set the privacy status. For more information about privacy in Mobile Core, please see Privacy and GDPR API's.

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.

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

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

setWrapperType

You can use the setWrapperType API to set the wrapper type when the SDK is being used in a cross-platform environment.

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

start

The start API triggers Mobile Core to start event processing. This should be used after the desired set of extensions have been registered using MobileCore.registerExtension() or <EXTENSION_NAME>.registerExtension(). A call to start will wait for any outstanding registrations to complete and then start event processing. You can use the callback to kickoff additional operations immediately after any operations kicked off during registration. This method should not be invoked more than once in your app.

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 on Create(){
super.onCreate();
MobileCore.setApplication(this);
UserProfile.registerExtension();
Lifecycle.registerExtension();
Signal.registerExtension();
MobileCore.start(new AdobeCallback () {
@Override
public void call(Object o) {
// implement callback
}
});
}
}

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.

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

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.

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

updateConfiguration

You can update the configuration programmatically by passing configuration keys and values to override the existing configuration using updateConfiguration API. For more information about configuration in Mobile Core, please refer to the Configuration API reference.

Public classes

Java

AdobeCallback

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

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

Copied to your clipboard
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.
  • SERVER_ERROR - There was a server error.
  • NETWORK_ERROR - There was a network error.
  • INVALID_REQUEST - There was an invalid request.
  • INVALID_RESPONSE - There was an invalid response.

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
}
});

Additional information

To learn what context data is, please read the documentation on context data.

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.