API Reference

extensionVersion

The extensionVersion() API returns the version of the client-side Consent extension.

Android Kotlin

data-slots=heading, code
data-repeat=2

Syntax

fun extensionVersion(): String

Example

val extensionVersion = Consent.extensionVersion()

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static String extensionVersion();

Example

String extensionVersion = Consent.extensionVersion();

iOS Swift

data-slots=heading, code
data-repeat=2

Syntax

static var extensionVersion: String

Example

let extensionVersion = Consent.extensionVersion

iOS Objective-C

data-slots=heading, code
data-repeat=2

Syntax

+ (nonnull NSString*) extensionVersion;

Example

NSString *extensionVersion = [AEPMobileEdgeConsent extensionVersion];

getConsents

Retrieves the current consent preferences stored in the Consent extension.

Android Kotlin

data-slots=heading, code
data-repeat=2

Syntax

fun getConsents(callback: AdobeCallback<Map<String, Any>>)

Example

Consent.getConsents { currentConsents ->
    // Handle currentConsents
}

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static void getConsents(final AdobeCallback<Map<String, Object>> callback);

Example

Consent.getConsents(new AdobeCallback<Map<String, Object>>() {
    @Override
    public void call(Map<String, Object> currentConsents) {
        // Handle currentConsents
    }
});

iOS Swift

data-slots=heading, code
data-repeat=2

Syntax

static func getConsents(completion: @escaping ([String: Any]?, Error?) -> Void)

Example

Consent.getConsents { currentConsents, error in
    // Handle currentConsents
}

iOS Objective-C

data-slots=heading, code
data-repeat=2

Syntax

+ (void) getConsents:^ (NSDictionary<NSString *,id> * _Nullable, NSError * _Nullable)

Example

[AEPMobileEdgeConsent getConsents:^(NSDictionary *currentConsents, NSError *error){
    // Handle currentConsents
}];

registerExtension

data-variant=warning
data-slots=text1, text2
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.

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static void registerExtension();

Example

Consent.registerExtension();

iOS Swift

Use the MobileCore API to register the Edge Consent extension.

data-slots=heading, code
data-repeat=2

Syntax

static func registerExtensions(_ extensions: [NSObject.Type],
                               _ completion: (() -> Void)? = nil)

Example

import AEPEdgeConsent

...
MobileCore.registerExtensions([Consent.self])

iOS Objective-C

Use the AEPMobileCore API to register the Edge Consent extension.

data-slots=heading, code
data-repeat=2

Syntax

+ (void) registerExtensions: (NSArray<Class*>* _Nonnull) extensions
                  completion: (void (^ _Nullable)(void)) completion;

Example

@import AEPEdgeConsent;

...
[AEPMobileCore registerExtensions:@[AEPMobileEdgeConsent.class] completion:nil];

updateConsents

Merges the existing consents with the given consents. Duplicate keys will take the value of those passed in the API.

data-variant=info
data-slots=text
Since Android 3.0.2 and iOS 5.0.1, Consent.update requests ignore repeated updates that match current consent preferences when received within one second of the previous request.
data-variant=info
data-slots=text1, text2, text3, text4, text5
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:
// 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:
    "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.

Android Kotlin

data-slots=heading, code
data-repeat=2

Syntax

fun update(consents: Map<String, Any>)

Example

// 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"] = collectConsents

Consent.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"] = collectConsents

Consent.update(consents)

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static void update(final Map<String, Object> consents);

Example

// 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);

iOS Swift

data-slots=heading, code
data-repeat=2

Syntax

static func update(with consents: [String: Any])

Example

// 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)

iOS Objective-C

data-slots=heading, code
data-repeat=2

Syntax

+ (void) updateWithConsents:(NSDictionary<NSString *,id> * _Nonnull)

Example

// 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}];