API Reference

extensionVersion

Returns the version of the client-side Consent extension.
Android
iOS — Swift

Java

Syntax

1
public static String extensionVersion();
Copied!

Example

1
Consent.extensionVersion();
Copied!

Swift

Syntax

1
public static let extensionVersion
Copied!

Example

1
Consent.extensionVersion
Copied!

Objective-C

Syntax

1
public static let extensionVersion
Copied!

Example

1
[AEPMobileEdgeConsent extensionVersion];
Copied!

getConsents

Retrieves the current consent preferences stored in the Consent extension.
Android
iOS — Swift

Java

Syntax

1
public static void getConsents(final AdobeCallback<Map<String, Object>> callback);
Copied!
  • 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

1
Consent.getConsents(new AdobeCallback<Map<String, Object>>() {
2
@Override
3
public void call(Map<String, Object> currentConsents) {
4
// handle currentConsents
5
}
6
});
Copied!

Swift

Syntax

1
static func getConsents(completion: @escaping ([String: Any]?, Error?) -> Void)
Copied!
  • 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

1
Consent.getConsents { currentConsents, error in
2
// handle currentConsents
3
}
Copied!

Objective-C

Syntax

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

Example

1
[AEPMobileEdgeConsent getConsents:^(NSDictionary *currentConsents, NSError *error){
2
// handle currentConsents
3
}];
Copied!

registerExtension

Registers the Edge Consent extension with the Mobile Core SDK.
Android
iOS — Swift

Java

Syntax

1
public static void registerExtension();
Copied!

Example

1
Consent.registerExtension();
Copied!

Swift

Use the MobileCore API to register the Edge Consent extension.

Syntax

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

Example

1
MobileCore.registerExtensions([Consent.self, ...], {
2
// processing after registration
3
})
Copied!

Objective-C

Use the AEPMobileCore API to register the Edge Consent extension.

Syntax

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

Example

1
[AEPMobileCore registerExtensions:@[AEPMobileEdgeConsent.class, ...] completion:^{
2
// processing after registration
3
}];
Copied!

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

Java

Syntax

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

Examples

1
// example 1, updating users collect consent to 'yes'
2
final Map<String, Object> collectConsents = new HashMap<>();
3
collectConsents.put("collect", new HashMap<String, String>() {
4
{
5
put("val", "y");
6
}
7
});
8
9
final Map<String, Object> consents = new HashMap<>();
10
consents.put("consents", collectConsents);
11
12
Consent.update(consents);
13
14
// example 2, updating users collect consent to 'no'
15
final Map<String, Object> collectConsents = new HashMap<>();
16
collectConsents.put("collect", new HashMap<String, String>() {
17
{
18
put("val", "n");
19
}
20
});
21
22
final Map<String, Object> consents = new HashMap<>();
23
consents.put("consents", collectConsents);
24
25
Consent.update(consents);
Copied!

Swift

Syntax

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

Examples

1
// example 1, updating users collect consent to 'yes'
2
let collectConsent = ["collect": ["val": "y"]]
3
let currentConsents = ["consents": collectConsent]
4
Consent.update(with: currentConsents)
5
6
// example 2, updating users collect consent to 'no'
7
let collectConsent = ["collect": ["val": "n"]]
8
let currentConsents = ["consents": collectConsent]
9
Consent.update(with: currentConsents)
Copied!

Objective-C

Syntax

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

Examples

1
// example 1, updating users collect consent to 'yes'
2
NSDictionary *collectConsent = @{ @"collect": @{@"val": @"y"};
3
[AEPMobileEdgeConsent updateWithConsents:@{@"consents": collectConsent}];
4
5
// example 2, updating users collect consent to 'no'
6
NSDictionary *collectConsent = @{ @"collect": @{@"val": @"n"};
7
[AEPMobileEdgeConsent updateWithConsents:@{@"consents": collectConse}];
Copied!
Last modified 3mo ago