Edit in GitHubLog an issue

Java

Syntax

Copied to your clipboard
public static String extensionVersion()

Example

Copied to your clipboard
String extensionVersion = Identity.extensionVersion();

Kotlin

Example

Copied to your clipboard
val extensionVersion = Identity.extensionVersion()

Swift

Syntax

Copied to your clipboard
static var extensionVersion: String

Example

Copied to your clipboard
let extensionVersion = EdgeIdentity.extensionVersion

Objective-C

Syntax

Copied to your clipboard
+ (nonnull NSString*) extensionVersion;

Example

Copied to your clipboard
NSString *extensionVersion = [AEPMobileEdgeIdentity extensionVersion];

Java

Syntax

Copied to your clipboard
public static void getExperienceCloudId(final AdobeCallback<String> callback);
  • callback is invoked after the ECID is available. The callback may be invoked on a different thread.

Example

Copied to your clipboard
Identity.getExperienceCloudId(new AdobeCallback<String>() {
@Override
public void call(String id) {
// Handle the ID returned here
}
});

Kotlin

Example

Copied to your clipboard
Identity.getExperienceCloudId { id ->
// Handle the ID returned here
}

Swift

Syntax

Copied to your clipboard
static func getExperienceCloudId(completion: @escaping (String?, Error?) -> Void)
  • completion is invoked after the ECID is available. The default timeout is 1000ms.

Example

Copied to your clipboard
Identity.getExperienceCloudId { (ecid, error) in
if let error = error {
// Handle the error here
} else {
// Handle the retrieved ID here
}
}

Objective-C

Syntax

Copied to your clipboard
+ (void) getExperienceCloudId:^(NSString * _Nullable ecid, NSError * _Nullable error)completion

Example

Copied to your clipboard
[AEPMobileEdgeIdentity getExperienceCloudId:^(NSString *ecid, NSError *error) {
// handle the error and the retrieved ID here
}];

Java

Syntax

Copied to your clipboard
public static void getIdentities(final AdobeCallback<IdentityMap> callback);
  • callback is invoked after the identities are available. The return format is an instance of IdentityMap. The callback may be invoked on a different thread.

Example

Copied to your clipboard
Identity.getIdentities(new AdobeCallback<IdentityMap>() {
@Override
public void call(IdentityMap identityMap) {
// Handle the IdentityMap returned here
}
});

Kotlin

Example

Copied to your clipboard
Identity.getIdentities { identityMap ->
// Handle the IdentityMap returned here
}

Swift

Syntax

Copied to your clipboard
static func getIdentities(completion: @escaping (IdentityMap?, Error?) -> Void)
  • completion is invoked after the identities are available. The default timeout is 1000ms. The return format is an instance of IdentityMap.

Example

Copied to your clipboard
Identity.getIdentities { (identityMap, error) in
if let error = error {
// Handle the error here
} else {
// Handle the retrieved identitites here
}
}

Objective-C

Syntax

Copied to your clipboard
+ (void) getIdentities:^(AEPIdentityMap * _Nullable map, NSError * _Nullable error)completion

Example

Copied to your clipboard
[AEPMobileEdgeIdentity getIdentities:^(AEPIdentityMap *map, NSError *error) {
// handle the error and the retrieved ID here
}];

Java

Syntax

Copied to your clipboard
public static void getUrlVariables(final AdobeCallback<String> callback);
  • callback has a String value that contains the visitor identifiers as a query string after the service request is complete.

Example

Copied to your clipboard
Identity.getUrlVariables(new AdobeCallback<String>() {
@Override
public void call(String urlVariablesString) {
// Handle the URL query parameter string here
// For example, open the URL in a webView
WebView webView;
webView = (WebView)findViewById(R.id.your_webview); // Initialize with your webView
webview.loadUrl("https://example.com?" + urlVariablesString);
}
});

Kotlin

Example

Copied to your clipboard
Identity.getUrlVariables { urlVariablesString ->
// Handle the URL query parameter string here
// For example, open the URL in a webView
val webView = findViewById<WebView>(R.id.your_webview) // Initialize with your webView
webView.loadUrl("http://www.example.com?" + urlVariablesString)
}

Swift

Syntax

Copied to your clipboard
static func getUrlVariables(completion: @escaping (String?, Error?) -> Void)
  • completion is invoked with urlVariables containing the visitor identifiers as a query string, or with error if an unexpected error occurs or the request times out. The returned Error contains the AEPError code of the specific error. The default timeout is 1000ms.

Example

Copied to your clipboard
Identity.getUrlVariables { (urlVariables, error) in
if let error = error {
// Handle the error here
} else {
var urlStringWithVisitorData: String = "https://example.com"
if let urlVariables: String = urlVariables {
urlStringWithVisitorData.append("?" + urlVariables)
}
guard let urlWithVisitorData: URL = URL(string: urlStringWithVisitorData) else {
// Handle the error, unable to construct URL
return
}
// Handle the retrieved urlVariables encoded string here
// APIs which update the UI must be called from main thread
DispatchQueue.main.async {
self.webView.load(URLRequest(url: urlWithVisitorData))
}
}
}

Objective-C

Syntax

Copied to your clipboard
+ (void) getUrlVariables:^(NSString * _Nullable urlVariables, NSError * _Nullable error)completion

Example

Copied to your clipboard
[AEPMobileEdgeIdentity getUrlVariables:^(NSString *urlVariables, NSError *error){
if (error) {
// Handle the error here
} else {
// Handle the URL query parameter string here
NSString* urlString = @"https://example.com";
NSString* urlStringWithVisitorData = [NSString stringWithFormat:@"%@?%@", urlString, urlVariables];
NSURL* urlWithVisitorData = [NSURL URLWithString:urlStringWithVisitorData];
// APIs which update the UI must be called from main thread
dispatch_async(dispatch_get_main_queue(), ^{
[[self webView] loadRequest:[NSURLRequest requestWithURL:urlWithVisitorData]];
}
}
}];

Java

Syntax

Copied to your clipboard
public static void registerExtension()

Example

Copied to your clipboard
import com.adobe.marketing.mobile.edge.identity.Identity
...
Identity.registerExtension();

Java

Syntax

Copied to your clipboard
public static void removeIdentity(final IdentityItem item, final String namespace);

Example

Copied to your clipboard
IdentityItem item = new IdentityItem("user@example.com");
Identity.removeIdentity(item, "Email");

Kotlin

Example

Copied to your clipboard
val item = IdentityItem("user@example.com")
Identity.removeIdentity(item, "Email")

Swift

Syntax

Copied to your clipboard
static func removeIdentity(item: IdentityItem, withNamespace: String)

Example

Copied to your clipboard
Identity.removeIdentity(item: IdentityItem(id: "user@example.com"), withNamespace: "Email")

Objective-C

Syntax

Copied to your clipboard
+ (void) removeIdentityItem:(AEPIdentityItem * _Nonnull) item
withNamespace: (NSString * _Nonnull) namespace

Example

Copied to your clipboard
AEPIdentityItem *item = [[AEPIdentityItem alloc] initWithId:@"user@example.com" authenticatedState:AEPAuthenticatedStateAuthenticated primary:false];
[AEPMobileEdgeIdentity removeIdentityItem:item withNamespace:@"Email"];

Java

Syntax

Copied to your clipboard
public static void setAdvertisingIdentifier(final String advertisingIdentifier);
  • advertisingIdentifier is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps.

Example

Copied to your clipboard
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import java.io.IOException;
import android.util.Log;
...
@Override
public void onResume() {
super.onResume();
...
new Thread(new Runnable() {
@Override
public void run() {
String advertisingIdentifier = null;
try {
AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
if (adInfo != null) {
if (!adInfo.isLimitAdTrackingEnabled()) {
advertisingIdentifier = adInfo.getId();
} else {
Log.d("ExampleActivity", "Limit Ad Tracking is enabled by the user, cannot process the advertising identifier");
}
}
} catch (IOException e) {
// Unrecoverable error connecting to Google Play services (e.g.,
// the old version of the service doesn't support getting AdvertisingId).
Log.d("ExampleActivity", "IOException while retrieving the advertising identifier " + e.getLocalizedMessage());
} catch (GooglePlayServicesNotAvailableException e) {
// Google Play services is not available entirely.
Log.d("ExampleActivity", "GooglePlayServicesNotAvailableException while retrieving the advertising identifier " + e.getLocalizedMessage());
} catch (GooglePlayServicesRepairableException e) {
// Google Play services is not installed, up-to-date, or enabled.
Log.d("ExampleActivity", "GooglePlayServicesRepairableException while retrieving the advertising identifier " + e.getLocalizedMessage());
}
MobileCore.setAdvertisingIdentifier(advertisingIdentifier);
}
}).start();
}

Kotlin

  • advertisingIdentifier is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps.

Example

Copied to your clipboard
import android.content.Context
import android.util.Log
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
import com.google.android.gms.common.GooglePlayServicesRepairableException
import java.io.IOException
...
suspend fun getGAID(applicationContext: Context): String {
var adID = ""
try {
val idInfo = AdvertisingIdClient.getAdvertisingIdInfo(applicationContext)
if (idInfo.isLimitAdTrackingEnabled) {
Log.d("ExampleActivity", "Limit Ad Tracking is enabled by the user, setting ad ID to \"\"")
return adID
}
Log.d("ExampleActivity", "Limit Ad Tracking disabled; ad ID value: ${idInfo.id}")
adID = idInfo.id
} catch (e: GooglePlayServicesNotAvailableException) {
Log.d("ExampleActivity", "GooglePlayServicesNotAvailableException while retrieving the advertising identifier ${e.localizedMessage}")
} catch (e: GooglePlayServicesRepairableException) {
Log.d("ExampleActivity", "GooglePlayServicesRepairableException while retrieving the advertising identifier ${e.localizedMessage}")
} catch (e: IOException) {
Log.d("ExampleActivity", "IOException while retrieving the advertising identifier ${e.localizedMessage}")
}
Log.d("ExampleActivity", "Returning ad ID value: $adID")
return adID
}

Call site:

Copied to your clipboard
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
...
// Create background coroutine scope to fetch ad ID value
val scope = CoroutineScope(Dispatchers.IO).launch {
val adID = sharedViewModel.getGAID(context.applicationContext)
Log.d("ExampleActivity", "Sending ad ID value: $adID to MobileCore.setAdvertisingIdentifier")
MobileCore.setAdvertisingIdentifier(adID)
}

In order to enable the collection of current advertising tracking user's selection based on the provided advertising identifier, you need to install and register the Consent for Edge Network extension and update the Edge Network extension dependency to minimum 1.4.1.

Starting from iOS 14+, applications must use the App Tracking Transparency framework to request user authorization before using the Identifier for Advertising (IDFA). To access IDFA and handle it correctly in your mobile application, see the Apple developer documentation about IDFA.

Swift

Syntax

Copied to your clipboard
@objc(setAdvertisingIdentifier:)
public static func setAdvertisingIdentifier(_ identifier: String?)
  • identifier is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps.

Example

Copied to your clipboard
import AdSupport
import AppTrackingTransparency
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
if #available(iOS 14, *) {
setAdvertisingIdentifierUsingTrackingManager()
} else {
// Fallback on earlier versions
setAdvertisingIdentifierUsingIdentifierManager()
}
}
func setAdvertisingIdentifierUsingIdentifierManager() {
var idfa:String = "";
if (ASIdentifierManager.shared().isAdvertisingTrackingEnabled) {
idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString;
} else {
Log.debug(label: "AppDelegateExample",
"Advertising Tracking is disabled by the user, cannot process the advertising identifier.");
}
MobileCore.setAdvertisingIdentifier(idfa);
}
@available(iOS 14, *)
func setAdvertisingIdentifierUsingTrackingManager() {
ATTrackingManager.requestTrackingAuthorization { (status) in
var idfa: String = "";
switch (status) {
case .authorized:
idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
case .denied:
Log.debug(label: "AppDelegateExample",
"Advertising Tracking is denied by the user, cannot process the advertising identifier.")
case .notDetermined:
Log.debug(label: "AppDelegateExample",
"Advertising Tracking is not determined, cannot process the advertising identifier.")
case .restricted:
Log.debug(label: "AppDelegateExample",
"Advertising Tracking is restricted by the user, cannot process the advertising identifier.")
}
MobileCore.setAdvertisingIdentifier(idfa)
}
}

Objective-C

Syntax

Copied to your clipboard
+ (void) setAdvertisingIdentifier: (NSString * _Nullable identifier);
  • identifier is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps.

Example

Copied to your clipboard
#import <AdSupport/ASIdentifierManager.h>
#import <AppTrackingTransparency/ATTrackingManager.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- ...
-
if (@available(iOS 14, *)) {
[self setAdvertisingIdentifierUsingTrackingManager];
} else {
// fallback to earlier versions
[self setAdvertisingIdentifierUsingIdentifierManager];
}
}
- (void) setAdvertisingIdentifierUsingIdentifierManager {
// setup the advertising identifier
NSString *idfa = nil;
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
} else {
[AEPLog debugWithLabel:@"AppDelegateExample"
message:@"Advertising Tracking is disabled by the user, cannot process the advertising identifier"];
}
[AEPMobileCore setAdvertisingIdentifier:idfa];
}
- (void) setAdvertisingIdentifierUsingTrackingManager API_AVAILABLE(ios(14)) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:
^(ATTrackingManagerAuthorizationStatus status){
NSString *idfa = nil;
switch(status) {
case ATTrackingManagerAuthorizationStatusAuthorized:
idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
break;
case ATTrackingManagerAuthorizationStatusDenied:
[AEPLog debugWithLabel:@"AppDelegateExample"
message:@"Advertising Tracking is denied by the user, cannot process the advertising identifier"];
break;
case ATTrackingManagerAuthorizationStatusNotDetermined:
[AEPLog debugWithLabel:@"AppDelegateExample"
message:@"Advertising Tracking is not determined, cannot process the advertising identifier"];
break;
case ATTrackingManagerAuthorizationStatusRestricted:
[AEPLog debugWithLabel:@"AppDelegateExample"
message:@"Advertising Tracking is restricted by the user, cannot process the advertising identifier"];
break;
}
[AEPMobileCore setAdvertisingIdentifier:idfa];
}];
}

Java

Syntax

Copied to your clipboard
public static void updateIdentities(final IdentityMap identityMap);

Example

Copied to your clipboard
IdentityItem item = new IdentityItem("user@example.com");
IdentityMap identityMap = new IdentityMap();
identityMap.addItem(item, "Email")
Identity.updateIdentities(identityMap);

Kotlin

Example

Copied to your clipboard
val item = IdentityItem("user@example.com")
val identityMap = IdentityMap()
identityMap.addItem(item, "Email")
Identity.updateIdentities(identityMap)

Swift

Syntax

Copied to your clipboard
static func updateIdentities(with map: IdentityMap)

Example

Copied to your clipboard
let identityMap = IdentityMap()
identityMap.addItem(item: IdentityItem(id: "user@example.com"), withNamespace: "Email")
Identity.updateIdentities(with: identityMap)

Objective-C

Syntax

Copied to your clipboard
+ (void) updateIdentities:(AEPIdentityMap * _Nonnull)map

Example

Copied to your clipboard
AEPIdentityItem *item = [[AEPIdentityItem alloc] initWithId:@"user@example.com" authenticatedState:AEPAuthenticatedStateAuthenticated primary:false];
AEPIdentityMap *map = [[AEPIdentityMap alloc] init];
[map addItem:item withNamespace:@"Email"];
[AEPMobileEdgeIdentity updateIdentities:map];

Java

Example

Copied to your clipboard
// Construct
IdentityMap identityMap = new IdentityMap();
// Add an item
IdentityItem item = new IdentityItem("user@example.com");
identityMap.addItem(item, "Email");
// Remove an item
IdentityItem item = new IdentityItem("user@example.com");
identityMap.removeItem(item, "Email");
// Get a list of items for a given namespace
List<IdentityItem> items = identityMap.getIdentityItemsForNamespace("Email");
// Get a list of all namespaces used in current IdentityMap
List<String> namespaces = identityMap.getNamespaces();
// Check if IdentityMap has no identities
boolean hasNotIdentities = identityMap.isEmpty();

Kotlin

Example

Copied to your clipboard
// Construct
val identityMap = IdentityMap()
// Add an item
val item = IdentityItem("user@example.com")
identityMap.addItem(item, "Email")
// Remove an item
val item = IdentityItem("user@example.com")
identityMap.removeItem(item, "Email")
// Get a list of items for a given namespace
val items = identityMap.getIdentityItemsForNamespace("Email")
// Get a list of all namespaces used in current IdentityMap
val namespaces = identityMap.getNamespaces()
// Check if IdentityMap has no identities
val hasNotIdentities = identityMap.isEmpty()

Swift

Example

Copied to your clipboard
// Initialize
let identityMap: IdentityMap = IdentityMap()
// Add an item
identityMap.add(item: IdentityItem(id: "user@example.com"), withNamespace: "Email")
// Remove an item
identityMap.remove(item: IdentityItem(id: "user@example.com", withNamespace: "Email"))
// Get a list of items for a given namespace
let items: [IdentityItem] = identityMap.getItems(withNamespace: "Email")
// Get a list of all namespaces used in current IdentityMap
let namespaces: [String] = identityMap.namespaces
// Check if IdentityMap has no identities
let hasNoIdentities: Bool = identityMap.isEmpty

Objective-C

Example

Copied to your clipboard
// Initialize
AEPIdentityMap* identityMap = [[AEPIdentityMap alloc] init];
// Add an item
AEPIdentityItem* item = [[AEPIdentityItem alloc] initWithId:@"user@example.com" authenticatedState:AEPAuthenticatedStateAuthenticated primary:false];
[identityMap addItem:item withNamespace:@"Email"];
// Remove an item
AEPIdentityItem* item = [[AEPIdentityItem alloc] initWithId:@"user@example.com" authenticatedState:AEPAuthenticatedStateAuthenticated primary:false];
[identityMap removeItem:item withNamespace:@"Email"];
// Get a list of items for a given namespace
NSArray<AEPIdentityItem*>* items = [identityMap getItemsWithNamespace:@"Email"];
// Get a list of all namespaces used in current IdentityMap
NSArray<NSString*>* namespaces = identityMap.namespaces;
// Check if IdentityMap has no identities
bool hasNoIdentities = identityMap.isEmpty;

Java

Example

Copied to your clipboard
// Construct
IdentityItem item = new IdentityItem("identifier");
IdentityItem item = new IdentityItem("identifier", AuthenticatedState.AUTHENTICATED, false);
// Getters
String id = item.getId();
AuthenticatedState state = item.getAuthenticatedState();
boolean primary = item.isPrimary();

Kotlin

Example

Copied to your clipboard
// Construct
val item = IdentityItem("identifier")
val item = IdentityItem("identifier", AuthenticatedState.AUTHENTICATED, false)
// Getters
val id = item.id
val state = item.authenticatedState
val primary = item.isPrimary

Swift

Example

Copied to your clipboard
// Initialize
let item = IdentityItem(id: "identifier")
let item = IdentityItem(id: "identifier", authenticatedState: .authenticated, primary: false)
// Getters
let id: String = item.id
let state: AuthenticatedState = item.authenticatedState
let primary: Bool = item.primary

Objective-C

Example

Copied to your clipboard
// Initialize
AEPIdentityItem* item = [[AEPIdentityItem alloc] initWithId:@"identity" authenticatedState:AEPAuthenticatedStateAuthenticated primary:false];
// Getters
NSString* id = primaryEmail.id;
long state = primaryEmail.authenticatedState;
bool primary = primaryEmail.primary;

Java

Syntax

Copied to your clipboard
public enum AuthenticatedState {
AMBIGUOUS("ambiguous"),
AUTHENTICATED("authenticated"),
LOGGED_OUT("loggedOut");
}

Kotlin

Syntax

Copied to your clipboard
enum class AuthenticatedState(val name: String) {
AMBIGUOUS("ambiguous"),
AUTHENTICATED("authenticated"),
LOGGED_OUT("loggedOut")
}

Syntax

Copied to your clipboard
@objc(AEPAuthenticatedState)
public enum AuthenticatedState: Int, RawRepresentable, Codable {
case ambiguous = 0
case authenticated = 1
case loggedOut = 2
}
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.