Identity
The Identity extension is bundled with Mobile Core and enables your app with the Experience Cloud ID (ECID). This service helps with the synchronization of Adobe and other customer identifiers.
On web or other platforms, there might situations where this extension might not be required, and the implementation of this SDK extension on mobile apps is required.
To get started with Identity, complete the following steps:
  1. 1.
    Add the Identity extension to your app.
  2. 2.
    Implement the SDK APIs to complete the following tasks:
    • Update customer IDs.
    • Append Adobe visitor data to a URL string.
    • Return customer IDs.
    • Retrieve Experience Cloud IDs.
    • Set advertising IDs.
    • Set the device notification for push notifications.

Add the Identity extension to your app

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
Java
Import the library:
1
import com.adobe.marketing.mobile.*;
Copied!
iOS
Import the Identity extension:
Swift
1
import AEPCore
2
import AEPIdentity
Copied!
Objective-C
1
@import AEPCore;
2
@import AEPIdentity;
Copied!
iOS
Import the Identity extension:
Swift
In Swift, the ACPCore includes ACPIdentity :
1
import ACPCore
Copied!
Objective-C
1
#import "ACPIdentity.h"
Copied!
Import the Identity extension:
JavaScript
1
import {ACPIdentity} from '@adobe/react-native-acpcore';
Copied!
Import the Identity extension:
Dart
1
import 'package:flutter_acpcore/flutter_acpidentity.dart';
Copied!

Cordova

After creating your Cordova app and adding the Android and iOS platforms, the Identity extension for Cordova can be added with this command:
1
cordova plugin add https://github.com/adobe/cordova-acpcore.git
Copied!

C#

After importing the ACPCore.unitypackage, the Identity extension for Unity can be added with following code in the MainScript
1
using com.adobe.marketing.mobile;
Copied!

C#

After adding the iOS ACPCore NuGet package or the Android ACPIdentity NuGet package, the Identity extension can be added by this import statement
1
using Com.Adobe.Marketing.Mobile;
Copied!

Register the Identity extension

The registerExtension() API registers the Identity extension with the Mobile Core extension. This API allows the extension to send and receive events to and from the Mobile SDK.
To register the Identity extension, use the following code sample:
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
After calling the setApplication() method in the onCreate() method, register the extension. If the registration was not successful, an InvalidInitException is thrown.
Java
1
public class MobiletApp extends Application {
2
@Override
3
public void onCreate() {
4
super.onCreate();
5
MobileCore.setApplication(this);
6
try {
7
Identity.registerExtension();
8
} catch (Exception e) {
9
//Log the exception
10
}
11
}
12
}
Copied!
iOS
Register the Identity extension in your app's didFinishLaunchingWithOptions function:
Swift
When including both Identity and Identity for Edge Network extensions, register the extensions using their full Swift module names.
1
MobileCore.registerExtensions([AEPIdentity.Identity.self, AEPEdgeIdentity.Identity.self, ...], { ... })
Copied!
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
MobileCore.registerExtensions([Identity.self, ...], {
3
...
4
})
5
}
Copied!
Objective-C
1
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2
[AEPMobileCore registerExtensions:@[AEPMobileIdentity.class, ...] completion:^{
3
...
4
}];
5
return YES;
6
}
Copied!
iOS
Register the Identity extension in your app's didFinishLaunchingWithOptions function:
Swift
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
ACPIdentity.registerExtension();
3
// Override point for customization after application launch.
4
return true;
5
}
Copied!
Objective-C
1
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2
[ACPIdentity registerExtension];
3
// Override point for customization after application launch.
4
return YES;
5
}
Copied!
JavaScript
When using React Native, registering Identity with Mobile Core should be done in native code which is shown under the Android and iOS tabs.
Dart
When using Flutter, registering Identity with Mobile Core should be done in native code which is shown under the Android and iOS tabs.
Cordova
When using Cordova, registering Identity with Mobile Core must be done in native code which is shown under the Android and iOS tabs.
C#
Register the Identity extension in your app's Start() function:
1
void Start() {
2
ACPIdentity.RegisterExtension();
3
}
Copied!
C#
iOS
Register the Identity extension in your app's FinishedLaunching() function:
1
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
2
{
3
global::Xamarin.Forms.Forms.Init();
4
LoadApplication(new App());
5
ACPIdentity.RegisterExtension();
6
7
// start core
8
ACPCore.Start(startCallback);
9
10
return base.FinishedLaunching(app, options);
11
}
12
13
private void startCallback()
14
{
15
// set launch config
16
ACPCore.ConfigureWithAppID("yourAppId");
17
}
Copied!
Android
Register the Identity extension in your app's OnCreate() function:
1
protected override void OnCreate(Bundle savedInstanceState)
2
{
3
base.OnCreate(savedInstanceState);
4
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
5
LoadApplication(new App());
6
7
ACPIdentity.RegisterExtension();
8
9
// start core
10
ACPCore.Start(new CoreStartCompletionCallback());
11
}
12
13
class CoreStartCompletionCallback : Java.Lang.Object, IAdobeCallback
14
{
15
public void Call(Java.Lang.Object callback)
16
{
17
// set launch config
18
ACPCore.ConfigureWithAppID("yourAppId");
19
}
20
}
Copied!
Previously known as MCID, the Experience Cloud ID (ECID) uniquely identifies each visitor in the Adobe Experience Platform and is a 38-character ID.
After the configuration is complete, an ECID is generated and, where applicable, is included on all Analytics and Audience Manager hits. Other IDs, such as custom and automatically-generated IDs, continue to be sent with each hit.

Version of the Identity extension

The extensionVersion() API returns the version of the Identity extension that is registered with the Mobile Core extension.
To get the version of the Identity extension, use the following code sample:
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
Java
1
String identityExtensionVersion = Identity.extensionVersion();
Copied!
iOS
Swift
1
var identityExtensionVersion = Identity.extensionVersion
Copied!
Objective-C
1
NSString *identityExtensionVersion = [AEPMobileIdentity extensionVersion];
Copied!
iOS
Swift
1
var identityExtensionVersion = ACPIdentity.extensionVersion()
Copied!
Objective-C
1
NSString *identityExtensionVersion = [ACPIdentity extensionVersion];
Copied!
JavaScript
1
ACPIdentity.extensionVersion().then(identityExtensionVersion => console.log("Identity version: " + identityExtensionVersion));
Copied!
Dart
1
String identityExtensionVersion = await FlutterACPIdentity.extensionVersion;
Copied!
Cordova
1
ACPIdentity.extensionVersion(function (handleCallback) {
2
console.log("AdobeExperienceSDK: ACPIdentity version: " + handleCallback)
3
}, function (handleError) {
4
console.log("AdobeExperenceSDK: failed to get extension version : " + handleError)
5
});
Copied!
C#
1
string identityVersion = ACPIdentity.ExtensionVersion();
Copied!
C#
1
string identityVersion = ACPIdentity.ExtensionVersion();
Copied!

Visitor tracking between an app and the mobile web

If your app opens mobile web content, you need to ensure that visitors are not identified separately as they move between the native and mobile web.

Visitor IDs in apps

The Mobile SDK generates a unique visitor ID when the app is installed. This ECID is stored in persistent memory on the mobile device and is sent with every hit. The ECID is removed when the user uninstalls the app or when the user sets the Mobile SDK global privacy status to optedout.
When the Mobile SDK privacy status is set to optedout, and the ECID is removed, a new unique visitor ID (ECID) is generated when the user sets the global privacy status to optedin.
App visitor IDs persist through upgrades.

Visitor IDs in the mobile web

Typical mobile web implementations use the same standard analytics s_code.js or AppMeasurement.js that is used in desktop sites. The JavaScript libraries have their own methods of generating unique visitor IDs, which causes a different visitor ID to be generated when you open mobile web content from your app.
To use the same visitor ID in the app and mobile web and pass the visitor ID to the mobile web in the URL, complete the following steps:

Implementing visitor tracking between an app and the mobile web

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
Java
To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:
1
Identity.appendVisitorInfoForURL("https://example.com", new AdobeCallback<String>() {
2
@Override
3
public void call(String urlWithAdobeVisitorInfo) {
4
//handle the new URL here
5
//For example, open the URL on the device browser
6
//
7
Intent i = new Intent(Intent.ACTION_VIEW);
8
i.setData(Uri.parse(urlWithAdobeVisitorInfo));
9
startActivity(i);
10
}
11
});
Copied!
Alternately, starting in SDK version 1.4.0 (Identity version 1.1.0), you can call getUrlVariables and build your own URL:
1
Identity.getUrlVariables(new AdobeCallback<String>() {
2
@Override
3
public void call(String stringWithAdobeVisitorInfo) {
4
//handle the URL query parameter string here
5
//For example, open the URL on the device browser
6
//
7
Intent i = new Intent(Intent.ACTION_VIEW);
8
i.setData(Uri.parse("https://example.com?" + urlWithAdobeVisitorInfo));
9
startActivity(i);
10
}
11
});
Copied!
To append visitor information to the URL that is being used to open the web view, call appendToUrl:
Swift
1
let url = URL(string: "https://example.com")
2
Identity.appendTo(url: url) { appendedUrl, error in
3
if error != nil {
4
// handle error here
5
} else {
6
// handle appended url here
7
}
8
}
Copied!
Objective-C
1
NSURL *sampleUrl = [NSURL URLWithString:@"https://example.com"];
2
[AEPMobileIdentity appendToUrl:sampleUrl completion:^(NSURL * _Nullable appendedUrl, NSError *error) {
3
if (error != nil) {
4
// Handle error here
5
} else {
6
// Handle appended url here
7
}
8
}];
Copied!
Alternately, you can call getUrlVariables and build your own URL:
Swift
1
Identity.getUrlVariables { urlVariables, error in
2
if error != nil {
3
// handle error here
4
} else {
5
if let url = URL(string: "https://example.com?\(urlVariables ?? "")") {
6
DispatchQueue.main.async {
7
UIApplication.shared.open(url)
8
}
9
}
10
}
11
}
Copied!
Objective-C
1
[AEPMobileIdentity getUrlVariables:^(NSString * _Nullable urlVariables, NSError *error) {
2
NSString *sampleURLString = @"https://example.com";
3
if (error != nil) {
4
// Handle variables being nil
5
} else {
6
NSString *stringWithData = [NSString stringWithFormat:@"%@?%@", sampleURLString, urlVariables];
7
NSURL *appendedUrl = [NSURL URLWithString:stringWithData];
8
dispatch_async(dispatch_get_main_queue(), ^{
9
[[UIApplication sharedApplication] openURL:appendedUrl options:@{} completionHandler:nil];
10
});
11
}
12
}];
Copied!
Objective-C
To append visitor information to the URL that is being used to open the web view, call appendToUrl:
1
NSURL* url = [[NSURL alloc] initWithString:@"www.example.com"];
2
[ACPIdentity appendToUrl:url withCallback:^(NSURL * _Nullable urlWithVisitorData) {
3
// handle the appended url here
4
}];
Copied!
Alternately, starting with SDK version 2.3.0 (ACPIdentity version 2.1.0), you can call getUrlVariables and build your own URL:
1
[ACPIdentity getUrlVariables:^(NSString * _Nullable urlVariables) {
2
// handle the URL query parameter string here
3
NSString* urlString = @"https://example.com";
4
NSString* urlStringWithVisitorData = [NSString stringWithFormat:@"%@?%@", urlString, urlVariables];
5
NSURL* urlWithVisitorData = [NSURL URLWithString:urlStringWithVisitorData];
6
[[UIApplication sharedApplication] openURL:urlWithVisitorData options:@{} completionHandler:^(BOOL success) {
7
// handle openURL success
8
}];
9
}];
Copied!
JavaScript
To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:
1
ACPIdentity.appendVisitorInfoForURL("www.example.com").then(urlWithVistorData => console.log("Url with Visitor Data = " + urlWithVisitorData));
Copied!
Alternately, starting with SDK version 1.0.5, you can call getUrlVariables and build your own URL:
1
ACPIdentity.getUrlVariables().then(urlVariables => console.log("query params = " + urlVariables));
Copied!
Dart
To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:
1
String result = "";
2
3
try {
4
result = await FlutterACPIdentity.appendToUrl("www.example.com");
5
} on PlatformException {
6
log("Failed to append URL");
7
}
Copied!
Alternately, starting with SDK version 1.0.0-beta.1, you can call getUrlVariables and build your own URL:
1
String result = "";
2
3
try {
4
result = await FlutterACPIdentity.urlVariables;
5
} on PlatformException {
6
log("Failed to get url variables");
7
}
Copied!
Cordova
To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:
1
ACPIdentity.appendVisitorInfoForUrl("https://example.com", function(handleCallback) {
2
console.log("AdobeExperenceSDK: Url with Visitor Data = " + handleCallback);
3
}, function(handleError) {
4
console.log("AdobeExperenceSDK: Failed to append URL : " + handleError);
5
});
Copied!
Alternately, you can call getUrlVariables and build your own URL:
1
ACPIdentity.getUrlVariables(function (handleCallback) {
2
console.log("AdobeExperienceSDK: Url variables: " + handleCallback);
3
}, function (handleError) {
4
console.log("AdobeExperenceSDK: Failed to retrieve url variables : " + handleError);
5
});
Copied!
C#
To append visitor information to the URL that is being used to open the web view, call AppendToUrl:
1
[MonoPInvokeCallback(typeof(AdobeIdentityAppendToUrlCallback))]
2
public static void HandleAdobeIdentityAppendToUrlCallback(string url)
3
{
4
print("Url is : " + url);
5
}
6
ACPIdentity.AppendToUrl("https://www.adobe.com", HandleAdobeIdentityAppendToUrlCallback);
Copied!
Alternately, you can call GetUrlVariables and build your own URL:
1
[MonoPInvokeCallback(typeof(AdobeGetUrlVariables))]
2
public static void HandleAdobeGetUrlVariables(string urlVariables)
3
{
4
print("Url variables are : " + urlVariables);
5
}
6
ACPIdentity.GetUrlVariables(HandleAdobeGetUrlVariables);
Copied!
C#
To append visitor information to the URL that is being used to open the web view, call AppendToUrl:
iOS
1
ACPIdentity.AppendToUrl(url, callback => {
2
Console.WriteLine("Appended url: " + callback);
3
});
Copied!
To append visitor information to the URL that is being used to open the web view, call AppendVisitorInfoForUrl:
Android
1
ACPIdentity.AppendVisitorInfoForURL("https://example.com", new StringCallback());
2
3
class StringCallback : Java.Lang.Object, IAdobeCallback
4
{
5
public void Call(Java.Lang.Object stringContent)
6
{
7
if (stringContent != null)
8
{
9
Console.WriteLine("Appended url: " + stringContent);
10
}
11
else
12
{
13
Console.WriteLine("null content in string callback");
14
}
15
}
16
}
Copied!
Alternately, you can call GetUrlVariables and build your own URL:
iOS
1
ACPIdentity.GetUrlVariables(callback => {
2
Console.WriteLine("Url variables: " + callback);
3
});
Copied!
Android
1
ACPIdentity.GetUrlVariables(new StringCallback());
2
3
class StringCallback : Java.Lang.Object, IAdobeCallback
4
{
5
public void Call(Java.Lang.Object stringContent)
6
{
7
if (stringContent != null)
8
{
9
Console.WriteLine("Url variables: " + stringContent);
10
}
11
else
12
{
13
Console.WriteLine("null content in string callback");
14
}
15
}
16
}
Copied!
The ID service code on the destination domain extracts the ECID from the URL instead of sending a request to Adobe for a new ID. The ID service code on the destination page uses this ECID to track the visitor. On hits from the mobile web content, verify that the mid parameter exists on each hit, and that this value matches the midvalue that is being sent by the app code.
Last modified 24d ago