API Reference

extensionVersion

Returns the version of the client-side Consent extension.

Android
iOS — Swift
Android

Java

Syntax

public static String extensionVersion();

Example

Consent.extensionVersion();
iOS — Swift

Swift

Syntax

public static let extensionVersion

Example

Consent.extensionVersion

Objective-C

Syntax

public static let extensionVersion

Example

[AEPMobileEdgeConsent extensionVersion];

getConsents

Retrieves the current consent preferences stored in the Consent extension.

Android
iOS — Swift
Android

Java

Syntax

public static void getConsents(final AdobeCallback<Map<String, Object>> callback);
  • callback - callback invoked with the current consents of the extension. If an AdobeCallbackWithError is provided, an AdobeError, can be retruned in the eventuality of any error that occured while getting the user consents. The callback may be invoked on a different thread.

Example

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

Swift

Syntax

static 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

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

Objective-C

Syntax

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

Example

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

registerExtension

Registers the Edge Consent extension with the Mobile Core SDK.

Android
iOS — Swift
Android

Java

Syntax

public static void registerExtension();

Example

Consent.registerExtension();
iOS — Swift

Swift

Use the MobileCore API to register the Edge Consent extension.

Syntax

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

Example

MobileCore.registerExtensions([Consent.self, ...], {
// processing after registration
})

Objective-C

Use the AEPMobileCore API to register the Edge Consent extension.

Syntax

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

Example

[AEPMobileCore registerExtensions:@[AEPMobileEdgeConsent.class, ...] completion:^{
// processing after registration
}];

updateConsents

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

Note: After a user has selected collect consent no (n), the SDK will not allow you to set the users collect consent to yes (y).

Android
iOS — Swift
Android

Java

Syntax

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

Examples

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

Swift

Syntax

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

Examples

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

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

Examples

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