This document lists the APIs provided by MobileCore, along with sample code snippets on how to properly use the APIs.
For more in-depth information about the Mobile Core, visit the official SDK documentation on Mobile Core.
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.MobileCore
final String coreVersion = MobileCore.extensionVersion();
val coreVersion: String = MobileCore.extensionVersion()
The SDK log verbosity can be adjusted to one of the following modes: ERROR
, WARNING
, DEBUG
, VERBOSE
.
MobileCore.setLogLevel(LoggingMode.VERBOSE);
MobileCore.setLogLevel(LoggingMode.VERBOSE)
final LoggingMode loggingMode = MobileCore.getLogLevel();
val loggingMode: LoggingMode = MobileCore.getLogLevel()
The wrapper type can be set to one of the follwing types: NONE
, REACT_NATIVE
, FLUTTER
, CORDOVA
, UNITY
, XAMARIN
.
MobileCore.setWrapperType(WrapperType.REACT_NATIVE);
MobileCore.setWrapperType(WrapperType.REACT_NATIVE)
Use the setApplication
api to pass the Android Application instance to SDK. This allows the SDK to monitor the lifecycle of your Android application.
public class YourApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
}
}
class YourApp : Application() {
override fun onCreate() {
super.onCreate()
MobileCore.setApplication(this)
}
}
You can use the getApplication()
api to get the Android Application instance that was previously set via MobileCore.setApplication()
final Application app = MobileCore.getApplication();
val app = MobileCore.getApplication()
import com.adobe.marketing.mobile.Identity
import com.adobe.marketing.mobile.Signal
...
MobileCore.registerExtensions(
Arrays.asList(Identity.EXTENSION, Signal.EXTENSION, ...), new AdobeCallback<Object>() {
// handle callback
});
import com.adobe.marketing.mobile.Identity
import com.adobe.marketing.mobile.Signal
...
MobileCore.registerExtensions(Arrays.asList(Identity.EXTENSION, Signal.EXTENSION, ...)){
// handle callback
}
MobileCore.registerEventListener(EventType.ANALYTICS, EventSource.REQUEST_CONTENT, new AdobeCallback<Event>() {
@Override
public void call(Event value) {
// handle callback
}
});
MobileCore.registerEventListener(EventType.ANALYTICS, EventSource.REQUEST_CONTENT) { event ->
// handle callback
}
MobileCore.configureWithAppId
api can be used to download and apply the configuration for the provided app Id.
MobileCore.configureWithAppId("YOUR_APP_ID");
MobileCore.configureWithAppId("YOUR_APP_ID")
You can bundle a JSON configuration file in the app's assets
folder to replace or complement the configuration that was downloaded by using the Configure with App ID per environment approach.
MobileCore.configureWithFileInAssets("SampleBundledJSONConfigFile.json");
MobileCore.configureWithFileInAssets("SampleBundledJSONConfigFile.json")
MobileCore.configureWithFileInPath("absolute/path/to/YourJSONConfigfile.json");
MobileCore.configureWithFileInPath("absolute/path/to/YourJSONConfigfile.json")
You can update the configuration programmatically by passing configuration keys and values to override the existing configuration via MobileCore.updateConfiguration()
api
Keys that are not found on the current configuration are added when this method is followed. Null values are allowed and replace existing configuration values.
Map<String, Object> data = new HashMap<>();
data.put("global.privacy", "optedout");
MobileCore.updateConfiguration(data);
val data: Map<String, Any?> = mapOf(
"global.privacy" to "optedout",
"sampleKey" to "sampleValue"
)
MobileCore.updateConfiguration(data)
You can clear programmatic configuration changes made using MobileCore.updteConfiguration()
api via MobileCore.clearUpdatedConfiguration()
api.
MobileCore.clearUpdatedConfiguration();
MobileCore.clearUpdatedConfiguration()
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);
val eventData: Map<String, Any?> = mapOf("sampleKey" to "sampleValue")
val sampleEvent = Event.Builder("Sample Event Name", "Sample EventType", "Sample Event Source")
.setEventData(eventData)
.build()
MobileCore.dispatchEvent(sampleEvent)
final Map<String, Object> eventData = new HashMap<>();
eventData.put("sampleKey", "sampleValue");
final Event sampleEvent = new Event.Builder("SampleEventName", "SampleEventType", "SampleEventSource")
.setEventData(eventData)
.build();
MobileCore.dispatchEventWithResponseCallback(sampleEvent, 5000L, new AdobeCallbackWithError<Event>() {
// implement callback
});
val eventData: Map<String, Any?> = mapOf("sampleKey" to "sampleValue")
val sampleEvent = Event.Builder("SampleEventName", "SampleEventType", "SampleEventSource")
.setEventData(eventData)
.build()
MobileCore.dispatchEvent(sampleEvent, 5000L) {
// implement callback
}
MobileCore.setAdvertisingIdentifier("YOUR_ADVERTISING_IDENTIFIER");
MobileCore.setAdvertisingIdentifier("YOUR_ADVERTISING_IDENTIFIER")
MobileCore.setPushIdentifier("YOUR_PUSH_IDENTIFIER");
MobileCore.setPushIdentifier("YOUR_PUSH_IDENTIFIER")
final Map<String, String> piiData = new HashMap<>();
piiData.put("piiDataKey", "piiDataValue");
MobileCore.collectPii(piiData);
val piiData: Map<String, Any?> = mapOf("piiDataKey" to "sampleValue")
MobileCore.collectPii(piiData)
final Map<String, Object> messageInfo = new HashMap<>();
messageInfo.put("sampleKey", "sampleValue");
MobileCore.collectMessageInfo(messageInfo);
val messageInfo: Map<String, Any?> = mapOf("sampleKey" to "sampleValue")
MobileCore.collectMessageInfo(messageInfo)
Privacy status can be set to one of the following values OPT_IN
, OPT_OUT
, UNKNOWN
.
MobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_IN);
MobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_IN)
MobileCore.getPrivacyStatus(new AdobeCallback<MobilePrivacyStatus>() {
@Override
public void call(MobilePrivacyStatus privacyStatus) {
// handle callback
}
});
MobileCore.getPrivacyStatus{ privacyStatus ->
// handle callback
}
MobileCore.getSdkIdentities(new AdobeCallback<String>() {
@Override
public void call(String sdkIdentitiesJson) {
// handle callback
}
});
MobileCore.getSdkIdentities { sdkIdentitiesJson ->
// handle callback
}
MobileCore.resetIdentities();
MobileCore.resetIdentities()
final Map<String, String> sampleContextData = new HashMap<>();
messageInfo.put("sampleKey", "sampleValue");
MobileCore.trackAction("SampleActionName", sampleContextData);
val sampleContextData: Map<String, String?> = mapOf("sampleKey" to "sampleValue")
MobileCore.trackAction("SampleActionName", sampleContextData)
final Map<String, String> sampleContextData = new HashMap<>();
messageInfo.put("sampleKey", "sampleValue");
MobileCore.trackState("SampleState", sampleContextData);
val sampleContextData: Map<String, String?> = mapOf("sampleKey" to "sampleValue")
MobileCore.trackAction("SampleState", sampleContextData)
final Map<String, String> sampleContextData = new HashMap<>();
messageInfo.put("sampleKey", "sampleValue");
MobileCore.lifecycleStart(sampleContextData);
val sampleContextData: Map<String, String?> = mapOf("sampleKey" to "sampleValue")
MobileCore.lifecycleStart(sampleContextData)
MobileCore.lifecyclePause();
MobileCore.lifecyclePause()