API Reference
extensionVersion
The extensionVersion() API returns the version of the client-side Consent extension.
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet extensionVersion = Consent.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *extensionVersion = [AEPMobileEdgeConsent extensionVersion];
Java
Syntax
Copied to your clipboardpublic static String extensionVersion();
Example
Copied to your clipboardString extensionVersion = Consent.extensionVersion();
Kotlin
Example
Copied to your clipboardval extensionVersion = Consent.extensionVersion()
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet extensionVersion = Consent.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *extensionVersion = [AEPMobileEdgeConsent extensionVersion];
getConsents
Retrieves the current consent preferences stored in the Consent extension.
Java
Syntax
Copied to your clipboardpublic static void getConsents(final AdobeCallback<Map<String, Object>> callback);
- callback - callback invoked with the current consents of the extension. If an
AdobeCallbackWithError
is provided, anAdobeError
, can be returned in the eventuality of any error that occurred while getting the user consents. The callback may be invoked on a different thread.
Example
Copied to your clipboardConsent.getConsents(new AdobeCallback<Map<String, Object>>() {@Overridepublic void call(Map<String, Object> currentConsents) {// Handle currentConsents}});
Kotlin
Example
Copied to your clipboardConsent.getConsents { currentConsents ->// Handle currentConsents}
Swift
Syntax
Copied to your clipboardstatic func getConsents(completion: @escaping ([String: Any]?, Error?) -> Void)
- completion - Invoked with the current consent preferences or an
AEPError
if an unexpected error occurs or the request timed out. It may be invoked on a different thread.
Example
Copied to your clipboardConsent.getConsents { currentConsents, error in// Handle currentConsents}
Objective-C
Syntax
Copied to your clipboard+ (void) getConsents:^ (NSDictionary<NSString *,id> * _Nullable, NSError * _Nullable)
Example
Copied to your clipboard[AEPMobileEdgeConsent getConsents:^(NSDictionary *currentConsents, NSError *error){// Handle currentConsents}];
Java
Syntax
Copied to your clipboardpublic static void getConsents(final AdobeCallback<Map<String, Object>> callback);
- callback - callback invoked with the current consents of the extension. If an
AdobeCallbackWithError
is provided, anAdobeError
, can be returned in the eventuality of any error that occurred while getting the user consents. The callback may be invoked on a different thread.
Example
Copied to your clipboardConsent.getConsents(new AdobeCallback<Map<String, Object>>() {@Overridepublic void call(Map<String, Object> currentConsents) {// Handle currentConsents}});
Kotlin
Example
Copied to your clipboardConsent.getConsents { currentConsents ->// Handle currentConsents}
Swift
Syntax
Copied to your clipboardstatic func getConsents(completion: @escaping ([String: Any]?, Error?) -> Void)
- completion - Invoked with the current consent preferences or an
AEPError
if an unexpected error occurs or the request timed out. It may be invoked on a different thread.
Example
Copied to your clipboardConsent.getConsents { currentConsents, error in// Handle currentConsents}
Objective-C
Syntax
Copied to your clipboard+ (void) getConsents:^ (NSDictionary<NSString *,id> * _Nullable, NSError * _Nullable)
Example
Copied to your clipboard[AEPMobileEdgeConsent getConsents:^(NSDictionary *currentConsents, NSError *error){// Handle currentConsents}];
registerExtension
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use MobileCore.registerExtensions()
API instead.
updateConsents
Merges the existing consents with the given consents. Duplicate keys will take the value of those passed in the API.
Java
Syntax
Copied to your clipboardpublic static void update(final Map<String, Object> consents);
- consents - A
Map
of consents defined based on Privacy/Personalization/Marketing Preferences (Consents) XDM Schema.
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'final Map<String, Object> collectConsents = new HashMap<>();collectConsents.put("collect", new HashMap<String, String>() {{put("val", "y");}});final Map<String, Object> consents = new HashMap<>();consents.put("consents", collectConsents);Consent.update(consents);// Example 2, updating users collect consent to 'no'final Map<String, Object> collectConsents = new HashMap<>();collectConsents.put("collect", new HashMap<String, String>() {{put("val", "n");}});final Map<String, Object> consents = new HashMap<>();consents.put("consents", collectConsents);Consent.update(consents);
Kotlin
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'val collectConsents = mutableMapOf<String, Any>()collectConsents["collect"] = mutableMapOf("val" to "y")val consents = mutableMapOf<String, Any>()consents["consents"] = collectConsentsConsent.update(consents)// Example 2, updating users collect consent to 'no'val collectConsents = mutableMapOf<String, Any>()collectConsents["collect"] = mutableMapOf("val" to "n")val consents = mutableMapOf<String, Any>()consents["consents"] = collectConsentsConsent.update(consents)
Swift
Syntax
Copied to your clipboardstatic func update(with consents: [String: Any])
- consents - A
[String: Any]
of consents defined based on Privacy/Personalization/Marketing Preferences (Consents) XDM Schema.
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'let collectConsent = ["collect": ["val": "y"]]let currentConsents = ["consents": collectConsent]Consent.update(with: currentConsents)// Example 2, updating users collect consent to 'no'let collectConsent = ["collect": ["val": "n"]]let currentConsents = ["consents": collectConsent]Consent.update(with: currentConsents)
Objective-C
Syntax
Copied to your clipboard+ (void) updateWithConsents:(NSDictionary<NSString *,id> * _Nonnull)
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'NSDictionary *collectConsent = @{ @"collect": @{@"val": @"y"};[AEPMobileEdgeConsent updateWithConsents:@{@"consents": collectConsent}];// Example 2, updating users collect consent to 'no'NSDictionary *collectConsent = @{ @"collect": @{@"val": @"n"};[AEPMobileEdgeConsent updateWithConsents:@{@"consents": collectConsent}];
Java
Syntax
Copied to your clipboardpublic static void update(final Map<String, Object> consents);
- consents - A
Map
of consents defined based on Privacy/Personalization/Marketing Preferences (Consents) XDM Schema.
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'final Map<String, Object> collectConsents = new HashMap<>();collectConsents.put("collect", new HashMap<String, String>() {{put("val", "y");}});final Map<String, Object> consents = new HashMap<>();consents.put("consents", collectConsents);Consent.update(consents);// Example 2, updating users collect consent to 'no'final Map<String, Object> collectConsents = new HashMap<>();collectConsents.put("collect", new HashMap<String, String>() {{put("val", "n");}});final Map<String, Object> consents = new HashMap<>();consents.put("consents", collectConsents);Consent.update(consents);
Kotlin
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'val collectConsents = mutableMapOf<String, Any>()collectConsents["collect"] = mutableMapOf("val" to "y")val consents = mutableMapOf<String, Any>()consents["consents"] = collectConsentsConsent.update(consents)// Example 2, updating users collect consent to 'no'val collectConsents = mutableMapOf<String, Any>()collectConsents["collect"] = mutableMapOf("val" to "n")val consents = mutableMapOf<String, Any>()consents["consents"] = collectConsentsConsent.update(consents)
Swift
Syntax
Copied to your clipboardstatic func update(with consents: [String: Any])
- consents - A
[String: Any]
of consents defined based on Privacy/Personalization/Marketing Preferences (Consents) XDM Schema.
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'let collectConsent = ["collect": ["val": "y"]]let currentConsents = ["consents": collectConsent]Consent.update(with: currentConsents)// Example 2, updating users collect consent to 'no'let collectConsent = ["collect": ["val": "n"]]let currentConsents = ["consents": collectConsent]Consent.update(with: currentConsents)
Objective-C
Syntax
Copied to your clipboard+ (void) updateWithConsents:(NSDictionary<NSString *,id> * _Nonnull)
Example
Copied to your clipboard// Example 1, updating users collect consent to 'yes'NSDictionary *collectConsent = @{ @"collect": @{@"val": @"y"};[AEPMobileEdgeConsent updateWithConsents:@{@"consents": collectConsent}];// Example 2, updating users collect consent to 'no'NSDictionary *collectConsent = @{ @"collect": @{@"val": @"n"};[AEPMobileEdgeConsent updateWithConsents:@{@"consents": collectConsent}];
When Consent.update
API is called, the Consent extension uses Adobe Standard 2.0 to communicate with the Edge Network. Additionally, the property metadata
is set to the time at which the API is called.
The following example shows when Consent.update
is called to set collect consent to y
:
Copied to your clipboard// Example in iOS (Swift), updating user's collect consent to 'yes'let collectConsent = ["collect": ["val": "y"]]let currentConsents = ["consents": collectConsent]Consent.update(with: currentConsents)
Bellow you can see the snippet of the request payload sent to the Edge Network:
Copied to your clipboard"consent": [{"standard": "Adobe","version": "2.0","value": {"metadata": {"time" : "2023-10-03T17:23:04.443Z"},"collect": {"val": "y"}}}]
For additional information about the management of consent preferences, please refer to the Privacy and GDPR documentation.