Identity API reference
appendToURL / appendVisitorInfoForURL
This API appends Adobe visitor information to the query component of the specified URL.
If the provided URL is null or empty, it is returned as is. Otherwise, the following information is added to the query component of the specified URL and is returned in the callback function:
-
The
adobe_mcattribute is a URL encoded list that contains:MCMID- Experience Cloud ID (ECID)MCORGID- Experience Cloud Org IDMCAID- Analytics Tracking ID (AID), if available from the Analytics extensionTS- A timestamp taken when this request was made
-
The optional
adobe_aa_vidattribute is the URL-encoded Analytics Custom Visitor ID (VID), if previously set in the Analytics extension.
This API is designed to handle the following URL formats:
scheme://authority/path?query=param#fragment
In this example, the Adobe visitor data is appended as:
scheme://authority/path?query=param&adobe_mc=TS%3Dtimestamp%7CMCMID%3Decid%7CMCORGID%3Decorgid%40AdobeOrg#fragment
Similarly, URLs without a query component:
scheme://authority/path#fragment
The Adobe visitor data is appended as:
scheme://authority/path?adobe_mc=TS%3Dtimestamp%7CMCMID%3Decid%7CMCORGID%3Decorgid%40AdobeOrg#fragment
In these examples the adobe_mc parameters are separated by "|" (pipe) and are encoded.
adobe_mc = TS=XXXXXX|MCMID=XXXXXX|MCAID=XXXXXX|MCORGID=XXXXXX@AdobeOrg
If your application uses more complicated URLs, such as Angular URLs, you should use getUrlVariables.
Android Java
This API can be called with AdobeCallback or AdobeCallbackWithError for retrieving the attributes from the Mobile SDK. When AdobeCallbackWithError is provided, this API uses a default timeout of 500ms. If the operation times out or an unexpected error occurs, the fail method is called with the appropriate AdobeError.
- baseUrl is the URL to which the visitor information needs to be appended. If the visitor information is nil or empty, the URL is returned as is.
- callback is invoked after the updated URL is available.
data-slots=heading, code
data-repeat=2
Syntax
public static void appendVisitorInfoForURL(
@NonNull final String baseURL, @NonNull final AdobeCallback<String> callback)
Example
Identity.appendVisitorInfoForURL("https://example.com", new AdobeCallback<String>() {
@Override
public void call(String urlWithAdobeVisitorInfo) {
//handle the new URL here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(urlWithAdobeVisitorInfo));
startActivity(i);
}
});
iOS Swift
- url is the URL to which the visitor information needs to be appended. If the visitor information is nil or empty, the URL is returned as is.
- completion is invoked after the updated URL is available or Error if an unexpected exception occurs or the request times out. The returned
Errorcontains the AEPError code of the specific error.
data-slots=heading, code
data-repeat=2
Syntax
static func appendTo(url: URL?, completion: @escaping (URL?, Error?) -> Void)
Example
Identity.appendTo(url: URL(string: "https://example.com")) { appendedURL, error in
if let error = error {
// handle error
} else {
// handle the appended url here
if let appendedURL = appendedURL {
// APIs which update the UI must be called from main thread
DispatchQueue.main.async {
self.webView.load(URLRequest(url: appendedURL!))
}
} else {
// handle error, nil appendedURL
}
}
})
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) appendToUrl: (NSURL * _Nullable baseUrl) completion: ^(NSURL * _Nullable urlWithVisitorData, NSError * _Nullable error) completion;
Example
NSURL* url = [NSURL URLWithString:@"https://example.com"];
[AEPMobileIdentity appendToUrl:url completion:^(NSURL * _Nullable urlWithVisitorData, NSError * _Nullable error) {
if (error) {
// handle error here
} else {
// handle the appended url here
if (urlWithVisitorData) {
// APIs which update the UI must be called from main thread
dispatch_async(dispatch_get_main_queue(), ^{
[[self webView] loadRequest:[NSURLRequest requestWithURL:urlWithVisitorData]];
}
} else {
// handle error, nil urlWithVisitorData
}
}
}];
extensionVersion
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 Java
data-slots=heading, code
data-repeat=2
Syntax
@NonNull
public static String extensionVersion();
Example
String identityExtensionVersion = Identity.extensionVersion();
iOS Swift
data-slots=heading, code
data-repeat=2
Syntax
static var extensionVersion: String
Example
let identityExtensionVersion = Identity.extensionVersion
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (nonnull NSString*) extensionVersion;
Example
NSString *identityVersion = [AEPMobileIdentity extensionVersion];
getExperienceCloudId
This API retrieves the Adobe Experience Cloud ID (ECID) that was generated when the app was initially launched and is stored in the Adobe Experience Cloud Identity Service.
This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall.
Android Java
This API can be called with AdobeCallback or AdobeCallbackWithError for retrieving the ECID from the Mobile SDK. When AdobeCallbackWithError is provided, this API uses a default timeout of 500ms. If the operation times out or an unexpected error occurs, the fail method is called with the appropriate AdobeError.
- callback is invoked after the ECID is available.
data-slots=heading, code
data-repeat=2
Syntax
public static void getExperienceCloudId(@NonNull final AdobeCallback<String> callback)
Example
Identity.getExperienceCloudId(new AdobeCallback<String>() {
@Override
public void call(String id) {
//Handle the ID returned here
}
});
iOS Swift
- completion is invoked with String after the ECID is available, or Error if an unexpected error occurs or the request times out. The returned
Errorcontains the AEPError code of the specific error.
data-slots=heading, code
data-repeat=2
Syntax
@objc(getExperienceCloudId:)
static func getExperienceCloudId(completion: @escaping (String?, Error?) -> Void)
Example
Identity.getExperienceCloudId { ecid, error in
if let error = error {
// handle error here
} else {
// handle the retrieved ID here
}
}
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) getExperienceCloudId: ^(NSString * _Nullable ecid, NSError * _Nullable error) completion;
Example
[AEPMobileIdentity getExperienceCloudId:^(NSString * _Nullable ecid, NSError *error) {
if (error) {
// handle error here
} else {
// handle the retrieved ID here
}
}];
getIdentifiers
This API returns all customer identifiers that were previously synced with the Adobe Experience Cloud Identity Service.
Android Java
This API can be called with AdobeCallback or AdobeCallbackWithError for retrieving the custom identifiers from the Mobile SDK. When AdobeCallbackWithError is provided, this API uses a default timeout of 500ms. If the operation times out or an unexpected error occurs, the fail method is called with the appropriate AdobeError.
- callback is invoked after the customer identifiers are available.
data-slots=heading, code
data-repeat=2
Syntax
public static void getIdentifiers(@NonNull final AdobeCallback<List<VisitorID>> callback)
Example
Identity.getIdentifiers(new AdobeCallback<List<VisitorID>>() {
@Override
public void call(List<VisitorID> idList) {
//Process the IDs here
}
});
iOS Swift
- completion is invoked with a list of Identifiable objects after the customer identifiers are available, or Error if an unexpected error occurs or the request times out. The returned
Errorcontains the AEPError code of the specific error.
data-slots=heading, code
data-repeat=2
Syntax
@objc(getIdentifiers:)
static func getIdentifiers(completion: @escaping ([Identifiable]?, Error?) -> Void)
Example
Identity.getIdentifiers { identifiers, error in
if let error = error {
// handle error here
} else {
// handle the retrieved identifiers here
}
}
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) getIdentifiers: ^(NSArray<id<AEPIdentifiables>> * _Nullable identifiers, NSError * _Nullable error) completion;
Example
[[AEPMobileIdentity getIdentifiers:^(NSArray<id<AEPIdentifiable>> * _Nullable identifiers, NSError *error) {
if (error) {
// handle error here
} else {
// handle the retrieved identifiers here
}
}];
getUrlVariables
This API gets the Adobe Experience Cloud Identity Service variables in URL query parameter form, and these variables will be consumed by the hybrid app. This method returns an appropriately formed string that contains the Experience Cloud Identity Service URL variables. There will be no leading (&) or (?) punctuation because the caller is responsible for placing the variables in their resulting URL in the correct location.
If an error occurs while retrieving the URL string, the callback handler will be called with a null value. Otherwise, the following information is added to the string that is returned in the callback:
-
The
adobe_mcattribute is an URL encoded list that contains:MCMID- Experience Cloud ID (ECID)MCORGID- Experience Cloud Org IDMCAID- Analytics Tracking ID (AID), if available from the Analytics extensionTS- A timestamp taken when this request was made
-
The optional
adobe_aa_vidattribute is the URL-encoded Analytics Custom Visitor ID (VID), if previously set in the Analytics extension.
Android Java
This method was added in Core version 1.4.0 and Identity version 1.1.0.
This API can be called with AdobeCallback or AdobeCallbackWithError for retrieving the attributes from the Mobile SDK. When AdobeCallbackWithError is provided, this API uses a default timeout of 500ms. If the operation times out or an unexpected error occurs, the fail method is called with the appropriate AdobeError.
- callback has an NSString value that contains the visitor identifiers as a query string after the service request is complete.
data-slots=heading, code
data-repeat=2
Syntax
public static void getUrlVariables(final AdobeCallback<String> callback);
Example
Identity.getUrlVariables(new AdobeCallback<String>() {
@Override
public void call(String stringWithAdobeVisitorInfo) {
//handle the URL query parameter string here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://example.com?" + urlWithAdobeVisitorInfo));
startActivity(i);
}
});
iOS Swift
- completion is invoked with String containing the visitor identifiers as a query string, or Error if an unexpected error occurs or the request times out. The returned
Errorcontains the AEPError code of the specific error. The default timeout of 500ms.
data-slots=heading, code
data-repeat=2
Syntax
@objc(getUrlVariables:)
static func getUrlVariables(completion: @escaping (String?, Error?) -> Void)
Example
Identity.getUrlVariables { (urlVariables, error) in
if let error = error {
// handle error
} else {
var urlStringWithVisitorData: String = "https://example.com"
if let urlVariables: String = urlVariables {
urlStringWithVisitorData.append("?" + urlVariables)
}
guard let urlWithVisitorData: URL = URL(string: urlStringWithVisitorData) else {
// handle error, unable to construct URL
return
}
// APIs which update the UI must be called from main thread
DispatchQueue.main.async {
self.webView.load(URLRequest(url: urlWithVisitorData))
}
}
}
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) getUrlVariables: ^(NSString * _Nullable urlVariables, NSError * _Nullable error) completion;
Example
[AEPMobileIdentity getUrlVariables:^(NSString * _Nullable urlVariables, NSError *error) {
if (error) {
// handle 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]];
}
}
}];
registerExtension
data-variant=warning
data-slots=heading, text1
MobileCore.registerExtensions() API instead.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.
Android Java
After calling the setApplication() method in the onCreate() method, register the extension. If the registration was not successful, an InvalidInitException is thrown.
public class MobileApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
try {
Identity.registerExtension();
} catch (Exception e) {
//Log the exception
}
}
}
resetIdentities
Clears all identities stored in the Identity extension and generates a new Experience Cloud ID (ECID). Using this API does not remove the identifiers from the server-side service.
This is a destructive action, since once an ECID is removed it cannot be reused. The new ECID generated by this API can increase metrics like unique visitors when a new user profile is created.
Some example use cases for this API are:
- During debugging, to see how new ECIDs (and other identifiers paired with it) behave with existing rules and metrics.
- A last-resort reset for when an ECID should no longer be used.
This API is not recommended for:
- Resetting a user's privacy settings; see Privacy and GDPR.
- Removing existing custom identifiers; use the
syncIdentifierAPI instead. - Removing a previously synced advertising identifier after the advertising tracking settings were changed by the user; use the
setAdvertisingIdentifierAPI instead.
See MobileCore.resetIdentities for more details.
setAdvertisingIdentifier
The advertising ID is preserved between app upgrades, is saved and restored during the standard application backup process, available via the Signals extension, and is removed at uninstall.
data-variant=info
data-slots=text
optedout, the advertising identifier is not set or stored.Android Java
- advertisingIdentifier is a string that provides developers with a simple, standard system to track the Ads through their apps.
Example
This is just an implementation example. For more information about advertising identifiers and how to handle them correctly in your mobile application, see Google Play Services documentation about AdvertisingIdClient.
This example requires Google Play Services to be configured in your mobile application. For instructions on how to import the Google Mobile Ads SDK and how to configure your ApplicationManifest.xml file, see Google Mobile Ads SDK setup.
data-slots=heading, code
data-repeat=2
Syntax
public static void setAdvertisingIdentifier(@Nullable final String advertisingIdentifier)
Example
...
@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 {
MobileCore.log(LoggingMode.DEBUG, "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).
MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "IOException while retrieving the advertising identifier " + e.getLocalizedMessage());
} catch (GooglePlayServicesNotAvailableException e) {
// Google Play services is not available entirely.
MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "GooglePlayServicesNotAvailableException while retrieving the advertising identifier " + e.getLocalizedMessage());
} catch (GooglePlayServicesRepairableException e) {
// Google Play services is not installed, up-to-date, or enabled.
MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "GooglePlayServicesRepairableException while retrieving the advertising identifier " + e.getLocalizedMessage());
}
MobileCore.setAdvertisingIdentifier(advertisingIdentifier);
}
}).start();
}
iOS Swift
To access IDFA and handle it correctly in your mobile application, see the Apple developer documentation about IDFA.
Starting iOS 14+, applications must use the App Tracking Transparency framework to request user authorization before using the Identifier for Advertising (IDFA).
- identifier is a string that provides developers with a simple, standard system to continue to track the Ads through their apps.
data-slots=heading, code
data-repeat=2
Syntax
@objc(setAdvertisingIdentifier:)
public static func setAdvertisingIdentifier(_ identifier: String?)
Example
import AdSupport
import AppTrackingTransparency
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
if #available(iOS 14, *) {
setAdvertisingIdentiferUsingTrackingManager()
} 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 setAdvertisingIdentiferUsingTrackingManager() {
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)
}
}
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) setAdvertisingIdentifier: (NSString * _Nullable identifier);
Example
#import <AdSupport/ASIdentifierManager.h>
#import <AppTrackingTransparency/ATTrackingManager.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- ...
-
if (@available(iOS 14, *)) {
[self setAdvertisingIdentiferUsingTrackingManager];
} 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) setAdvertisingIdentiferUsingTrackingManager 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];
}];
}
setPushIdentifier
This API sets the device token for push notifications in the SDK. If the current SDK privacy status is optedout, the push identifier is not set.
data-variant=info
data-slots=text
setPushIdentifier on each application launch to ensure the most up-to-date device token is set to the SDK. If no device token is available, null/nil should be passed.Android Java
- pushIdentifier is a string that contains the device token for push notifications.
data-slots=heading, code
data-repeat=2
Syntax
public static void setPushIdentifier(@Nullable final String pushIdentifier)
Example
//Retrieve the token from either GCM or FCM, and pass it to the SDK
MobileCore.setPushIdentifier(token);
iOS Swift
- deviceToken is a string that contains the device token for push notifications.
data-slots=heading, code
data-repeat=2
Syntax
@objc(setPushIdentifier:)
public static func setPushIdentifier(_ deviceToken: Data?)
Example
// Set the deviceToken that the APNs has assigned to the device
MobileCore.setPushIdentifier(deviceToken)
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) setPushIdentifier: (NSString * _Nullable deviceToken);
Example
// Set the deviceToken that the APNS has assigned to the device
[AEPMobileCore setPushIdentifier:deviceToken];
syncIdentifier
The syncIdentifier() and syncIdentifiers() APIs update the specified customer IDs with the Adobe Experience Cloud Identity Service.
These APIs synchronize the provided customer identifier type key and value with the authentication state to the Experience Cloud Identity Service. If the specified customer ID type exists in the service, this ID type is updated with the new ID and the authentication state. Otherwise, a new customer ID is added.
Starting with ACPIdentity v2.1.3 (iOS) and Identity v1.1.2 (Android) if the new identifier value is null or empty, this ID type is removed from the local storage, Identity shared state and not synced with the Experience Cloud Identity Service.
These IDs are preserved between app upgrades, are saved and restored during the standard application backup process, and are removed at uninstall.
If the current SDK privacy status is MobilePrivacyStatus.OPT_OUT, calling this method results in no operations being performed.
This API updates or appends the provided customer identifier type key and value with the given authentication state to the Experience Cloud Identity Service. If the specified customer ID type exists in the service, the ID is updated with the new ID and authentication state. Otherwise a new customer ID is added.
Android Java
- identifierType (String) contains the
identifier type, and this parameter should not be null or empty. The allowed characters are [A-Za-z0-9_.] - identifier (String) contains the
identifier value, and this parameter should not be null or empty. - authenticationState (AuthenticationState) indicates the authentication state of the user and contains one of the VisitorID.AuthenticationState values.
data-slots=heading, code
data-repeat=2
Syntax
public static void syncIdentifier(
@NonNull final String identifierType,
@Nullable final String identifier,
@NonNull final VisitorID.AuthenticationState authenticationState)
Example
Identity.syncIdentifier("idType",
"idValue",
VisitorID.AuthenticationState.AUTHENTICATED);
iOS Swift
- The identifierType (String) contains the
identifier type, and this parameter should not be null or empty. The allowed characters are [A-Za-z0-9_.] - The identifier (String) contains the
identifiervalue, and this parameter should not be null or empty. If either theidentifierTypeoridentifiercontains a null or an empty string, the identifier is ignored by the Identity extension. - The authenticationState (MobileVisitorAuthenticationState) value indicates the authentication state for the user and contains one of the MobileVisitorAuthenticationState values.
data-slots=heading, code
data-repeat=2
Syntax
@objc(syncIdentifierWithType:identifier:authenticationState:)
static func syncIdentifier(identifierType: String, identifier: String, authenticationState: MobileVisitorAuthenticationState)
Example
Identity.syncIdentifier(identifierType: "idType",
identifier: "idValue",
authentication: .unknown)
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) syncIdentifierWithType: (NSString * _Nonnull identifierType)
identifier: (NSString * _Nonnull identifier)
authentication: (enum AEPAuthenticationState authenticationState);
Example
[AEPMobileIdentity syncIdentifierWithType:@"idType"
identifier:@"idValue"
authenticationState:AEPMobileVisitorAuthStateUnknown];
syncIdentifiers
This API is an overloaded version, which does not include the parameter for the authentication state and it assumes a default value of VisitorID.AuthenticationState.UNKNOWN.
Android Java
- identifiers is a map that contains the identifiers with the Identifier type as the key, and the string identifier as the value. In each identifier pair, if the
identifier typecontains a null or an empty string, the identifier is ignored by the Identity extension.
data-slots=heading, code
data-repeat=2
Syntax
public static void syncIdentifiers(@NonNull final Map<String, String> identifiers)
Example
Map<String, String> identifiers = new HashMap<String, String>();
identifiers.put("idType1", "idValue1");
identifiers.put("idType2", "idValue2");
identifiers.put("idType3", "idValue3");
Identity.syncIdentifiers(identifiers);
iOS Swift
- The identifiers dictionary contains identifier type as the key and identifier as the value, both identifier type and identifier should be non empty and non nil values.
data-slots=heading, code
data-repeat=2
Syntax
@objc(syncIdentifiers:)
static func syncIdentifiers(identifiers: [String: String]?)
Example
let ids : [String: String] = ["idType1":"idValue1",
"idType2":"idValue2",
"idType3":"idValue3"];
Identity.syncIdentifiers(identifiers: ids)
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) syncIdentifiers: (NSDictionary<NSString *, NSString *> * _Nullable identifiers);
Example
NSDictionary *ids = @{@"idType1":@"idValue1",
@"idType2":@"idValue2",
@"idType3":@"idValue3"};
[AEPMobileIdentity syncIdentifiers:ids];
syncIdentifiers (overloaded)
The function of this API is the same as the syncIdentifier API. This API passes a list of identifiers, and each identifier contains an identifier type as the key and an identifier as the value. In each identifier pair, if the identifier type contains a null or an empty string, the identifier is ignored by the Identity extension.
Starting with ACPIdentity v2.1.3 (iOS) and Identity v1.1.2 (Android) if the new identifier value is null or empty, this ID type is removed from the local storage, Identity shared state and not synced with the Adobe Experience Cloud Identity Service.
Android Java
- identifiers is a map that contains IDs with the identifier type as the key, and the string identifier as the value.
- authState indicates the authentication state for the user, which contains one of the following VisitorID.AuthenticationState values.
data-slots=heading, code
data-repeat=2
Syntax
public static void syncIdentifiers(
@NonNull final Map<String, String> identifiers,
@NonNull final VisitorID.AuthenticationState authenticationState)
Example
Map<String, String> identifiers = new HashMap<String, String>();
identifiers.put("idType1", "idValue1");
identifiers.put("idType2", "idValue2");
identifiers.put("idType3", "idValue3");
Identity.syncIdentifiers(identifiers, VisitorID.AuthenticationState.AUTHENTICATED);
iOS Swift
- The identifiers dictionary contains identifier type as the key and identifier as the value, both identifier type and identifier should be non empty and non nil values.
- The authenticationState (MobileVisitorAuthenticationState) indicates the authentication state of the user and contains one of the MobileVisitorAuthenticationState values.
data-slots=heading, code
data-repeat=2
Syntax
@objc(syncIdentifiers:authenticationState:)
static func syncIdentifiers(identifiers: [String: String]?, authenticationState: MobileVisitorAuthenticationState)
Example
let ids : [String: String] = ["idType1":"idValue1",
"idType2":"idValue2",
"idType3":"idValue3"];
Identity.syncIdentifiers(identifiers: ids, authenticationState: .authenticated)
iOS Objective-C
data-slots=heading, code
data-repeat=2
Syntax
+ (void) syncIdentifiers: (NSDictionary<NSString *, NSString *> * _Nullable identifiers)
authentication: (enum AEPAuthenticationState authenticationState);
Example
NSDictionary *ids = @{@"idType1":@"idValue1",
@"idType2":@"idValue2",
@"idType3":@"idValue3"};
[AEPMobileIdentity syncIdentifiers:ids authenticationState:AEPMobileVisitorAuthStateAuthenticated];
Public classes
Android
AuthenticationState
This class is used to indicate the authentication state for the current VisitorID.
public enum AuthenticationState {
UNKNOWN,
AUTHENTICATED,
LOGGED_OUT;
}
VisitorID
This class is an identifier to be used with the Adobe Experience Cloud Identity Service.
public class VisitorID {
//Constructor
public VisitorID(String idOrigin, String idType, String id, VisitorID.AuthenticationState authenticationState);
public VisitorID.AuthenticationState getAuthenticationState();
public final String getId();
public final String getIdOrigin();
public final String getIdType();
}
iOS
MobileVisitorAuthenticationState
This is used to indicate the authentication state for the current Identifiable.
@objc(AEPMobileVisitorAuthState) public enum MobileVisitorAuthenticationState: Int, Codable {
case unknown = 0
case authenticated = 1
case loggedOut = 2
}
Identifiable
@objc(AEPIdentifiable) public protocol Identifiable {
/// Origin of the identifier
var origin: String? { get }
/// Type of the identifier
var type: String? { get }
/// The identifier
var identifier: String? { get }
/// The authentication state for the identifier
var authenticationState: MobileVisitorAuthenticationState { get }
}