V4 Mobile SDKs to Experience Platform Analytics migration

Configuration

The AEP Analytics extension uses Launch to configure the AEP SDK's. This replaces the ADBMobileConfig.json which the Mobile Services SDK used for configuration. To get started with the AEP SDK's:
    1.
    Create a mobile property on Launch. See Set up a mobile property for more information.
    2.
    Configure your mobile app with the create mobile property. The AEP Mobile Core extension provides general functionality required by all the Adobe AEP extensions. The Configuration extension is built into the Mobile Core and contains the configureWithAppId API. This API is used to link the Launch mobile property with your mobile app. The documentation for this API can be seen at the Configuration API Reference page. A code sample showing the usage of this API is provided below.
    3.
    Once all the AEP extensions are imported and configured correctly, remove the v4 Mobile SDK dependency. This step is mandatory and a mix of v4 and AEP API calls is not supported.
Android
iOS
If using Gradle, remove the v4 Mobile SDK dependency:
1
dependencies {
2
implementation 'com.adobe.mobile:adobeMobileLibrary:4.18.2'
3
...
4
}
Copied!
Alternatively, if the v4 Mobile SDK library is linked as a jar, search for adobeMobileLibrary in your project and remove the jar file.
If using Cocoapods, remove the v4 Mobile SDK dependency from the Podfile:
1
target 'YourTarget' do
2
pod 'AdobeMobileSDK'
3
...
4
end
Copied!
Alternatively, if the v4 Mobile SDK library is linked in Xcode, select the application target and go to Build Phases, then Link Binary With Libraries and remove AdobeMobileLibrary.a.

Analytics Migration Overview

For an overview of the API mapping between the Mobile Services SDK and AEP SDK's, see the API Change Log. This section will go over the Analytics specific changes made with the AEP Analytics extension.

Deprecated API

API
Notes
trackActionFromBackground (iOS)
Deprecated
trackLocation:data: (iOS, Android)
This functionality is available in the Places extension.
trackBeacon:Data: (iOS, Android)
Support modified, see guide
trackingClearCurrentBeacon (iOS, Android)
Support modified, see guide
trackLifetimeValueIncrease:data: (iOS, Android)
This functionality can be recreated using the Analytics and User Profile extensions.
trackTimedActionStart: (iOS, Android)
This functionality can be recreated using the Analytics and User Profile extensions.
trackTimedActionUpdate: (iOS, Android)
This functionality can be recreated using the Analytics and User Profile extensions.
trackTimedActionEnd: (iOS, Android)
This functionality can be recreated using the Analytics and User Profile extensions.
trackTimedActionExists: (iOS, Android)
This functionality can be recreated using the Analytics and User Profile extensions.

AEP SDK Installation and Setup

In your App's Application class add the AEP extension registration and configuration code:
Android
iOS
1
import com.adobe.marketing.mobile.MobileCore;
2
import com.adobe.marketing.mobile.Analytics;
3
import com.adobe.marketing.mobile.Identity;
4
5
@Override
6
public void onCreate(Bundle savedInstanceState) {
7
super.onCreate(savedInstanceState);
8
setContentView(R.layout.main);
9
10
MobileCore.setApplication(getApplication());
11
MobileCore.setLogLevel(LoggingMode.DEBUG);
12
try {
13
Analytics.registerExtension();
14
Identity.registerExtension();
15
MobileCore.start(new AdobeCallback() {
16
@Override
17
public void call(Object o) {
18
// add your app id from the "Environments" tab on Launch.
19
MobileCore.configureWithAppID("your-app-id");
20
}
21
});
22
} catch (InvalidInitException e) {
23
e.printStackTrace();
24
}
25
}
Copied!
Objective-C
1
#import "ACPCore.h"
2
#import "ACPAnalytics.h"
3
#import "ACPIdentity.h"
4
5
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
6
[ACPCore setLogLevel:ACPMobileLogLevelDebug];
7
[ACPAnalytics registerExtension];
8
[ACPIdentity registerExtension];
9
[ACPCore start:^{
10
// add your app id from the "Environments" tab on Launch.
11
[ACPCore configureWithAppId:@"your-app-id"];
12
}];
13
return YES;
14
}
Copied!
Swift
1
import ACPCore
2
import ACPAnalytics
3
import ACPIdentity
4
5
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
6
ACPCore.setLogLevel(ACPMobileLogLevel.debug)
7
ACPAnalytics.registerExtension()
8
ACPIdentity.registerExtension()
9
ACPCore.start(){
10
ACPCore.configureWithAppId("your-app-id")
11
}
12
return true
13
}
Copied!
For more details, see Add Analytics to your application.

API changes

Track App State and Track App Actions

Android
iOS

Mobile Services SDK

The Mobile Services SDK syntax and usage examples for these API are:
1
// syntax
2
public static void trackState(final String state, final Map<String, Object> contextData)
3
4
// usage
5
Analytics.trackState("MainPage", new HashMap<String, Object>() {{
6
put("firstVisit", true);
7
}});
Copied!
1
// syntax
2
public static void trackAction(final String action, final Map<String, Object> contextData)
3
4
// usage
5
Analytics.trackAction("linkClicked", new HashMap<String, Object>() {{
6
put("url", "https://www.adobe.com");
7
}});
Copied!

AEP SDK

The AEP SDK's have moved the trackAction and trackState APIs to the MobileCore extension. In addition, the context data Map has been changed from <String, Object> to <String, String>. The syntax is:
1
// syntax
2
public static void trackState(final String state, final Map<String, String> contextData)
3
4
// usage
5
MobileCore.trackState("MainPage", new HashMap<String, String>() {{
6
put("firstVisit", "true");
7
}});
Copied!
1
// syntax
2
public static void trackAction(final String action, final Map<String, String> contextData)
3
4
// usage
5
MobileCore.trackAction("linkClicked", new HashMap<String, String>() {{
6
put("url", "https://www.adobe.com");
7
}});
Copied!
The Mobile Services SDK syntax and usage examples for these API are:

Mobile Services SDK

1
// syntax
2
+ (void) trackState:(NSString *)state data:(NSDictionary *)data;
3
4
// usage
5
[ADBMobile trackState:@"MainPage" data:@{@"firstVisit":@true}];
Copied!
1
// syntax
2
+ (void) trackAction:(NSString *)action data:(NSDictionary *)data;
3
4
// usage
5
[ADBMobile trackAction:@"linkClicked" data:@{@"url":@"https://www.adobe.com"}];
Copied!

AEP SDK

The AEP SDK's have moved the trackAction and trackState API's to the MobileCore extension. In addition, the NSDictionary has been changed from <NSString, NSObject> to <NSString, NSString>. The syntax is:
1
+ (void) trackAction: (nullable NSString*) action data: (nullable NSDictionary<NSString*, NSString*>*) data;
Copied!
1
+ (void) trackState: (nullable NSString*) action data: (nullable NSDictionary<NSString*, NSString*>*) data;
Copied!
The usage examples are:
Objective-C
1
[ACPCore trackState:@"MainPage" data:@{@"firstVisit":@"true"}];
2
[ACPCore trackAction:@"linkClicked" data:@{@"url":@"https://www.adobe.com"}];
Copied!
Swift
1
ACPCore.trackState("MainPage", data: ["firstVisit": "true"])
2
ACPCore.trackAction("linkClicked", data: ["url": "https://www.adobe.com"])
Copied!

Privacy status changes in the AEP SDK

The privacy status API setPrivacyStatus and getPrivacyStatus can be found in the MobileCore. Like the Mobile Services SDK, the Analytics extension will follow these behaviors depending on the privacy status set:
Opted in: Analytics hits will be sent.
Unknown: Analytics hits will be queued.
Opted out: Analytics hits will be dropped.
Android
iOS

AEP SDK

The syntax and usage examples for setPrivacyStatus are:
1
// syntax
2
public static void setPrivacyStatus(final MobilePrivacyStatus privacyStatus);
3
4
// usage
5
MobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_IN);
6
MobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_OUT);
7
MobileCore.setPrivacyStatus(MobilePrivacyStatus.UNKNOWN);
Copied!
The syntax and usage examples for getPrivacyStatus are:
1
// syntax
2
void getPrivacyStatus(AdobeCallback<MobilePrivacyStatus> callback);
3
4
// usage
5
MobileCore.getPrivacyStatus(new AdobeCallback<MobilePrivacyStatus>() {
6
@Override
7
public void call(MobilePrivacyStatus status) {
8
System.out.println("privacy status: " + status);
9
}
10
});
Copied!
The callback is invoked after the privacy status is available. 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.

AEP SDK

The syntax for setPrivacyStatus is:
1
// syntax
2
+ (void) setPrivacyStatus: (ACPMobilePrivacyStatus) status;
Copied!
The syntax for getPrivacyStatus is:
1
// syntax
2
+ (void) getPrivacyStatus: (nonnull void (^) (ACPMobilePrivacyStatus status)) callback;
3
+ (void) getPrivacyStatusWithCompletionHandler: (nonnull void (^) (ACPMobilePrivacyStatus status, NSError* _Nullable error)) completionHandler;
Copied!
The callback is invoked after the privacy status is available.
If the API with the completion handler is used, the completion handler will be invoked with the current privacy status, or error if an unexpected error occurs or the request times out. The default timeout is 5000ms.
The usage example for getPrivacyStatus is:
Objective-C
1
[ACPCore getPrivacyStatus:^(ACPMobilePrivacyStatus status) {
2
switch (status) {
3
case ACPMobilePrivacyStatusOptIn: NSLog(@"Privacy Status: Opt-In");
4
case ACPMobilePrivacyStatusOptOut: NSLog(@"Privacy Status: Opt-Out");
5
case ACPMobilePrivacyStatusUnknown: NSLog(@"Privacy Status: Unknown");
6
default: break;
7
}
8
}];
9
10
[ACPCore getPrivacyStatusWithCompletionHandler:^(ACPMobilePrivacyStatus status, NSError * _Nullable error) {
11
if (error) {
12
// handle error here
13
} else {
14
// handle the retrieved privacy status
15
}
16
}];
Copied!
Swift
1
ACPCore.getPrivacyStatus({ status in
2
switch status {
3
case ACPMobilePrivacyStatus.optIn: print ("Privacy Status: Opt-In")
4
case ACPMobilePrivacyStatus.optOut: print("Privacy Status: Opt-Out")
5
case ACPMobilePrivacyStatus.unknown: print("Privacy Status: Unknown")
6
default: break
7
}
8
})
9
10
ACPCore.getPrivacyStatus(withCompletionHandler: { status, error in
11
if error != nil {
12
// handle error here
13
} else {
14
// handle the retrieved privacy status
15
}
16
})
Copied!
Last modified 14d ago