Mobile Core API reference

collectLaunchInfo

You can provide the user information to the SDK from various launch points in your application.
If the Adobe Analytics extension is enabled in your SDK, collecting this launch data results in an Analytics request being sent. Other extensions in the SDK might use the collected data, for example, as a rule condition for an In-App Message.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
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
1
public static func collectLaunchInfo(_ userInfo: [String: Any])
Copied!
Example
1
MobileCore.collectLaunchInfo(userInfo)
Copied!
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
1
@objc(collectLaunchInfo:)
2
public static func collectLaunchInfo(_ userInfo: [String: Any])
Copied!
Example
1
[AEPMobileCore collectLaunchInfo:launchOptions];
Copied!
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:
Syntax
1
(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Copied!
Example
1
[ACPCore collectLaunchInfo:launchOptions];
Copied!
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:)
Syntax
1
(void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Copied!
Example
1
AEPCore.collectLaunchInfo(userInfo)
Copied!

collectPii

The collectPii method lets the SDK to collect sensitive or personally identifiable information (PII).
Although this method enables the collection of sensitive data, no data is sent to any Adobe or other third-party endpoints. To send the data to an endpoint, use a PII type postback.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Java
Syntax
1
public static void collectPII(final Map<String, String> piiData);
Copied!
Example
1
Map<String, String> data = new HashMap<String, String>();
2
data.put("firstname", "customer");
3
//The rule to trigger a PII needs to be setup for this call
4
//to result in a network send
5
MobileCore.collectPII(data);
Copied!
Swift
Syntax
1
public static func collectPii(_ data: [String: Any])
Copied!
Example
1
MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
Copied!
Objective-C
Syntax
1
@objc(collectPii:)
2
public static func collectPii(_ data: [String: Any])
Copied!
Example
1
[AEPMobileCore collectPii:data:@{@"key1" : @"value1",
2
@"key2" : @"value2"
3
}];
Copied!
Objective-C
Syntax
1
(void) collectPii: (nonnull NSDictionary<NSString*, NSString*>*) data;
Copied!
Example
1
[ACPCore collectPii:data:@{@"key1" : "@value1",
2
@"key2" : "@value2"
3
}];
Copied!
Swift
Syntax
1
ACPCore.collectPii(data: [String : String])
Copied!
Example
1
MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
Copied!
Javascript
Syntax
1
ACPCore.collectPii(data: [String : String])
Copied!
Example
1
ACPCore.collectPii({"myPii": "data"});
Copied!
Swift
Syntax
1
ACPCore.collectPii(data: [String : String])
Copied!
Example
1
MobileCore.collectPii(["key1" : "value1","key2" : "value2"]);
Copied!

getApplication (Android only)

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
Java
MobileCore.getApplication will return null if the Application object was destroyed or if MobileCore.setApplication was not previously called.
Syntax
1
public static Application getApplication()
Copied!
Example
1
Application app = MobileCore.getApplication();
2
if (app != null) {
3
...
4
}
Copied!
C#
ACPCore.Application may be null if the Application object was destroyed or was not set in the Core.
Example
1
var app = ACPCore.Application;
2
if (app != null) {
3
...
4
}
Copied!

getLogLevel

This API gets the current log level being used in the SDK.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Unity
Xamarin
Java
Syntax
1
public static LoggingMode getLogLevel()
Copied!
Example
1
LoggingMode mode = MobileCore.getLogLevel();
Copied!
Swift
Note, the logLevel getter has been deprecated. There is a new API to get the log level in the Swift AEP 3.x SDKs:

Log.logFilter

Syntax
1
public static var logFilter: LogLevel
Copied!
This variable is part of the Log class within AEPServices.
Example
1
var logLevel = Log.logFilter
Copied!
Objective-C
Note, the logLevel getter has been deprecated. There is a new API to get the log level in the Swift AEP 3.x SDKs:

Log.logFilter

Syntax
1
@objc public static var logFilter: LogLevel
Copied!
Example
1
AEPLogLevel logLevel = [AEPLog logFilter];
Copied!
Objective-C

getLogLevel

Syntax
1
(ACPMobileLogLevel) logLevel;
Copied!
Example
1
var logLevel:ACPMobileLogLevel = [ACPCore logLevel];
Copied!
Swift

getLogLevel

Syntax
1
(ACPMobileLogLevel) logLevel;
Copied!
Example
1
let logLevel:ACPMobileLogLevel = ACPCore.logLevel();
Copied!
Javascript

getLogLevel

Example
1
ACPCore.getLogLevel().then(level => console.log("AdobeExperienceSDK: Log Level = " + level));
Copied!
C#

getLogLevel

Example
1
ACPCore.ACPMobileLogLevel logLevel = ACPCore.GetLogLevel();
Copied!
C#

getLogLevel

Example
1
var logLevel = ACPCore.LogLevel;
Copied!

getSdkIdentities

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)
Java
Syntax
1
void getSdkIdentities(AdobeCallback<String> callback);
Copied!
  • 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
1
MobileCore.getSdkIdentities(new AdobeCallback<String>() {
2
@Override
3
public void call(String value) {
4
// handle the json string
5
}
6
});
Copied!
Swift
Syntax
1
static func getSdkIdentities(completion: @escaping (String?, Error?) -> Void)
Copied!
  • 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
1
MobileCore.getSdkIdentities { (content, error) in
2
// handle completion
3
}
Copied!
Objective-C
Syntax
1
@objc(getSdkIdentities:)
2
static func getSdkIdentities(completion: @escaping (String?, Error?) -> Void)
Copied!
  • 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
1
[AEPMobileCore getSdkIdentities:^(NSString * _Nullable content, NSError * _Nullable error) {
2
if (error) {
3
// handle error here
4
} else {
5
// handle the retrieved identities
6
}
7
}];
Copied!
Objective-C
Syntax
1
(void) getSdkIdentities: (nullable void (^) (NSString* __nullable content)) callback;
2
(void) getSdkIdentitiesWithCompletionHandler: (nullable void (^) (NSString* __nullable content, NSError* _Nullable error)) completionHandler;
Copied!
  • 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
1
[ACPCore getSdkIdentities:^(NSString * _Nullable content){
2
NSLog(content);
3
4
[ACPCore getSdkIdentitiesWithCompletionHandler:^(NSString * _Nullable content, NSError * _Nullable error) {
5
if (error) {
6
// handle error here
7
} else {
8
// handle the retrieved identities
9
NSLog(content);
10
}
11
}];
Copied!
Swift
1
MobileCore.getSdkIdentities { (content, error) in
2
// handle completion
3
}
Copied!

log

This is the API used to log from the SDK.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Xamarin
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
1
public static void log(final LoggingMode mode, final String tag, final String message)
Copied!
Example
1
MobileCore.log(LoggingMode.DEBUG, "MyClassName", "Provided data was null");
Copied!
Output
1
D/AdobeExperienceSDK: MyClassName - Provided data was null
Copied!
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
1
public static func trace(label: String, _ message: String) {
2
public static func debug(label: String, _ message: String)
3
public static func warning(label: String, _ message: String) {
4
public static func error(label: String, _ message: String) {
Copied!
Example
1
Log.trace(label: "testLabel", "Test message")
2
Log.debug(label: "testLabel", "Test message")
3
Log.warning(label: "testLabel", "Test message")
4
Log.error(label: "testLabel", "Test message")
Copied!
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
1
@objc(traceWithLabel:message:)
2
public static func trace(label: String, _ message: String)
3
4
@objc(debugWithLabel:message:)
5
public static func debug(label: String, _ message: String)
6
7
@objc(warningWithLabel:message:)
8
public static func warning(label: String, _ message: String)
9
10
@objc(errorWithLabel:message:)
11
public static func error(label: String, _ message: String)
Copied!
Example
1
[AEPLog traceWithLabel:@"testLabel" message:@"testMessage"];
2
[AEPLog debugWithLabel:@"testLabel" message:@"testMessage"];
3
[AEPLog warningWithLabel:@"testLabel" message:@"testMessage"];
4
[AEPLog errorWithLabel:@"testLabel" message:@"testMessage"];
Copied!
Objective-C
The log messages from the Adobe Experience SDK are printed to the Apple System Log facility and use a common format that contains the tag AdobeExperienceSDK. For example, if logging an error message using ACPCore.log(), the printed output looks like [AdobeExperienceSDK ERROR <tag>]: message[AEP SDK ERROR - <testLabel>] Test message.
Syntax
1
+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;
Copied!
Example
1
[ACPCore log: ACPMobileLogLevelDebug, tag:@"MyClassName", message:@"Provided data was nil"];
Copied!
Output example
1
[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
Copied!
Swift
Syntax
1
+ (void) log: (ACPMobileLogLevel) logLevel tag: (nonnull NSString*) tag message: (nonnull NSString*) message;
Copied!
Example
1
ACPCore.log(ACPMobileLogLevel.debug, tag: "MyClassName", message: "Provided data was nil");
Copied!
Output example
1
[AdobeExperienceSDK DEBUG <MyClassName>]: Provided data was nil
Copied!

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
1
ACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");
Copied!
Note: ACPMobileLogLevel contains the following getters:
1
const ERROR = "ACP_LOG_LEVEL_ERROR";
2
const WARNING = "ACP_LOG_LEVEL_WARNING";
3
const DEBUG = "ACP_LOG_LEVEL_DEBUG";
4
const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";
Copied!

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
1
ACPCore.Log(ACPMobileLogLevel.Error, "xamarin tag", "xamarin message");
Copied!
1
[AdobeExperienceSDK ERROR <xamarin tag>]: xamarin message
Copied!
Android syntax
1
ACPCore.Log(LoggingMode.Error, "xamarin tag", "xamarin message");
Copied!
1
[AdobeExperienceSDK] xamarin tag - xamarin message
Copied!

registerExtension(s)

Extensions are registered with Mobile Core so that they can dispatch and listen for events.
Extension registration is mandatory. Attempting to make extension-specific API calls without registering the extension will lead to undefined behavior.
The following code snippets demonstrate how you can import and register the Mobile Core and Profile extensions. You can also see, for reference, how Identity, Lifecycle, Signal, Profile, and other extensions are imported and registered.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
After you register the extensions, call the start API in Mobile Core to initialize the SDK as shown below. This step is required to boot up the SDK for event processing. The following code snippet is provided as a sample reference.

Java

1
import com.adobe.marketing.mobile.AdobeCallback;
2
import com.adobe.marketing.mobile.Identity;
3
import com.adobe.marketing.mobile.InvalidInitException;
4
import com.adobe.marketing.mobile.Lifecycle;
5
import com.adobe.marketing.mobile.LoggingMode;
6
import com.adobe.marketing.mobile.MobileCore;
7
import com.adobe.marketing.mobile.Signal;
8
import com.adobe.marketing.mobile.UserProfile;
9
...
10
import android.app.Application;
11
...
12
public class MainApp extends Application {
13
...
14
@Override
15
public void on Create(){
16
super.onCreate();
17
MobileCore.setApplication(this);
18
MobileCore.setLogLevel(LoggingMode.DEBUG);
19
...
20
try {
21
UserProfile.registerExtension();
22
Identity.registerExtension();
23
Lifecycle.registerExtension();
24
Signal.registerExtension();
25
MobileCore.start(new AdobeCallback () {
26
@Override
27
public void call(Object o) {
28
MobileCore.configureWithAppID("<your_environment_id_from_Launch>");
29
}
30
});
31
} catch (InvalidInitException e) {
32
...
33
}
34
}
35
}
Copied!
For iOS Swift libraries, registration is changed to a single API call (as shown in the snippets below). Calling theMobileCore.start API is no longer required.
Swift
1
// AppDelegate.swift
2
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
3
MobileCore.registerExtensions([Signal.self, Lifecycle.self, UserProfile.self, Edge.self, AEPEdgeIdentity.Identity.self, Consent.self, AEPIdentity.Identity.self, Analytics.self], {
4
MobileCore.configureWith(appId: "yourLaunchEnvironmentID")
5
})
6
...
7
}
Copied!
Objective-C
1
// AppDelegate.m
2
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
3
[AEPMobileCore registerExtensions:@[AEPMobileSignal.class, AEPMobileLifecycle.class, AEPMobileUserProfile.class, AEPMobileEdge.class, AEPMobileEdgeIdentity.class, AEPMobileEdgeConsent.class, AEPMobileIdentity.class, AEPMobileAnalytics.class] completion:^{
4
[AEPMobileCore configureWithAppId: @"yourLaunchEnvironmentID"];
5
}];
6
...
7
}
Copied!
The following snippet shows an example of how to add the initialization code. Note that this may need to be adjusted, depending on how your application is structured.
Objective-C
1
#import "AppDelegate.h"
2
#import "ACPCore.h"
3
#import "ACPUserProfile.h"
4
#import "ACPIdentity.h"
5
#import "ACPLifecycle.h"
6
#import "ACPSignal.h"
7
...
8
@implementation AppDelegate
9
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
10
[ACPCore setLogLevel:ACPMobileLogLevelDebug];
11
[ACPCore configureWithAppId:@"<your_environment_id_from_Launch>"];
12
...
13
[ACPUserProfile registerExtension];
14
[ACPIdentity registerExtension];
15
[ACPLifecycle registerExtension];
16
[ACPSignal registerExtension];
17
const UIApplicationState appState = application.applicationState;
18
[ACPCore start:^{
19
// only start lifecycle if the application is not in the background
20
if (appState != UIApplicationStateBackground) {
21
[ACPCore lifecycleStart:nil];
22
}
23
}];
24
...
25
return YES;
26
}
27
28
@end
Copied!
Swift
1
import ACPCore
2
import ACPUserProfile
3
...
4
@UIApplicationMain
5
class AppDelegate: UIResponder, UIApplicationDelegate {
6
var window: UIWindow?
7
func application(_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool{
8
ACPCore.setLogLevel(.debug)
9
ACPCore.configure(withAppId: "<your_environment_id_from_Launch>")
10
...
11
ACPUserProfile.registerExtension()
12
ACPIdentity.registerExtension()
13
ACPLifecycle.registerExtension()
14
ACPSignal.registerExtension()
15
ACPCore.start {
16
ACPCore.lifecycleStart(nil)
17
}
18
...
19
return true
20
}
21
}
Copied!
For React Native apps, initialize the SDK using native code in your AppDelegate (iOS) and MainApplication (Android).

iOS

1
#import "ACPCore.h"
2
#import "ACPUserProfile.h"
3
#import "ACPIdentity.h"
4
#import "ACPLifecycle.h"
5
#import "ACPSignal.h"
6
...
7
@implementation AppDelegate
8
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
9
[ACPCore setLogLevel:ACPMobileLogLevelDebug];
10
[ACPCore configureWithAppId:@"<your_environment_id_from_Launch>"];
11
[ACPUserProfile registerExtension];
12
[ACPIdentity registerExtension];
13
[ACPLifecycle registerExtension];
14
[ACPSignal registerExtension];
15
16
const UIApplicationState appState = application.applicationState;
17
[ACPCore start:^{
18
// only start lifecycle if the application is not in the background
19
if (appState != UIApplicationStateBackground) {
20
[ACPCore lifecycleStart:nil];
21
}
22
}];
23
...
24
return YES;
25
}
26
27
@end
Copied!

Android

1
import com.adobe.marketing.mobile.AdobeCallback;
2
import com.adobe.marketing.mobile.Identity;
3
import com.adobe.marketing.mobile.InvalidInitException;
4
import com.adobe.marketing.mobile.Lifecycle;
5
import com.adobe.marketing.mobile.LoggingMode;
6
import com.adobe.marketing.mobile.MobileCore;
7
import com.adobe.marketing.mobile.Signal;
8
import com.adobe.marketing.mobile.UserProfile;
9
...
10
import android.app.Application;
11
...
12
public class MainApplication extends Application implements ReactApplication {
13
...
14
@Override
15
public void on Create(){
16
super.onCreate();
17
...
18
MobileCore.setApplication(this);
19
MobileCore.setLogLevel(LoggingMode.DEBUG);
20
MobileCore.setWrapperType(WrapperType.REACT_NATIVE);
21
22
try {
23
UserProfile.registerExtension();
24
Identity.registerExtension();
25
Lifecycle.registerExtension();
26
Signal.registerExtension();
27
MobileCore.start(new AdobeCallback () {
28
@Override
29
public void call(Object o) {
30
MobileCore.configureWithAppID("<your_environment_id_from_Launch>");
31
}
32
});
33
} catch (InvalidInitException e) {
34
...
35
}
36
}
37
}
Copied!

Dart

For Flutter apps, initialize the SDK using native code in your AppDelegate and MainApplication in iOS and Android, respectively.
The initialization code is located in the Flutter ACPCore Github README.
For Cordova apps, initialize the SDK using native code in your AppDelegate and MainApplication in iOS and Android, respectively.
iOS
1
// Import the SDK
2
#import "ACPCore.h"
3
#import "ACPLifecycle.h"
4
#import "ACPIdentity.h"
5
#import "ACPSignal.h"
6
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
7
// make sure to set the wrapper type at the beginning of initialization
8
[ACPCore setWrapperType:ACPMobileWrapperTypeCordova];
9
10
//...
11
[ACPCore configureWithAppId:@"yourAppId"];
12
[ACPIdentity registerExtension];
13
[ACPLifecycle registerExtension];
14
[ACPSignal registerExtension];
15
// Register any additional extensions
16
17
[ACPCore start:nil];
18
}
Copied!
Android
1
// Import the SDK
2
import com.adobe.marketing.mobile.MobileCore;
3
import com.adobe.marketing.mobile.Identity;
4
import com.adobe.marketing.mobile.Lifecycle;
5
import com.adobe.marketing.mobile.Signal;
6
import com.adobe.marketing.mobile.WrapperType;
7
8
@Override
9
public void onCreate() {
10
//...
11
MobileCore.setApplication(this);
12
MobileCore.configureWithAppID("yourAppId");
13
14
// make sure to set the wrapper type at the beginning of initialization
15
MobileCore.setWrapperType(WrapperType.CORDOVA);
16
17
try {
18
Identity.registerExtension();
19
Lifecycle.registerExtension();
20
Signal.registerExtension();
21
22
// Register any additional extensions
23
} catch (Exception e) {
24
// handle exception
25
}
26
27
MobileCore.start(null);
28
}
Copied!

C#

For Unity apps, initialize the SDK using the following code in the start function of the MainScript.
1
using com.adobe.marketing.mobile;
2
using using AOT;
3
4
public class MainScript : MonoBehaviour
5
{
6
[MonoPInvokeCallback(typeof(AdobeStartCallback))]
7
public static void HandleStartAdobeCallback()
8
{
9
ACPCore.ConfigureWithAppID("1423ae38-8385-8963-8693-28375403491d");
10
}
11
12
// Start is called before the first frame update
13
void Start()
14
{
15
if (Application.platform == RuntimePlatform.Android) {
16
ACPCore.SetApplication();
17
}
18
19
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);
20
ACPCore.SetWrapperType();
21
ACPIdentity.registerExtension();
22
ACPLifecycle.registerExtension();
23
ACPSignal.registerExtension();
24
ACPCore.Start(HandleStartAdobeCallback);
25
}
26
}
Copied!

C#

For Xamarin Forms applications, the SDK initialization differs, depending on the platform being targeted.
iOS
1
using Com.Adobe.Marketing.Mobile;
2
3
[Register("AppDelegate")]
4
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
5
{
6
//
7
// This method is invoked when the application has loaded and is ready to run. In this
8
// method you should instantiate the window, load the UI into it and then make the window
9
// visible.
10
//
11
// You have 17 seconds to return from this method, or iOS will terminate your application.
12
//
13
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
14
{
15
global::Xamarin.Forms.Forms.Init();
16
LoadApplication(new App());
17
18
// set the wrapper type
19
ACPCore.SetWrapperType(ACPMobileWrapperType.Xamarin);
20
21
// set launch config
22
ACPCore.ConfigureWithAppID("your-app-id");
23
24
// register SDK extensions
25
ACPIdentity.RegisterExtension();
26
ACPLifecycle.RegisterExtension();
27
ACPSignal.RegisterExtension();
28
29
// start core
30
ACPCore.Start(null);
31
}
Copied!
Android
1
using Com.Adobe.Marketing.Mobile;
2
3
[Activity(Label = "TestApp", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
4
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
5
{
6
protected override void OnCreate(Bundle savedInstanceState)
7
{
8
base.OnCreate(savedInstanceState);
9
10
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
11
LoadApplication(new App());
12
13
// set the wrapper type
14
ACPCore.SetWrapperType(WrapperType.Xamarin);
15
16
// register SDK extensions
17
ACPCore.Application = this.Application;
18
ACPIdentity.RegisterExtension();
19
ACPLifecycle.RegisterExtension();
20
ACPSignal.RegisterExtension();
21
22
// start core