API Reference

extensionVersion

The extensionVersion() API returns the version of the client-side Consent extension.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static String extensionVersion();
Copied!
Example
1
String extensionVersion = Consent.extensionVersion();
Copied!

Swift

Syntax
1
static var extensionVersion: String
Copied!
Example
1
let extensionVersion = Consent.extensionVersion
Copied!

Objective-C

Syntax
1
+ (nonnull NSString*) extensionVersion;
Copied!
Example
1
NSString *extensionVersion = [AEPMobileEdgeConsent extensionVersion];
Copied!

getConsents

Retrieves the current consent preferences stored in the Consent extension.
Android
iOS (AEP 3.x)

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 returned in the eventuality of any error that occurred 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
+ (void) getConsents:^ (NSDictionary<NSString *,id> * _Nullable, NSError * _Nullable)
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 (AEP 3.x)

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
static func registerExtensions(_ extensions: [NSObject.Type],
2
_ completion: (() -> Void)? = nil)
Copied!
Example
1
import AEPEdgeConsent
2
3
...
4
MobileCore.registerExtensions([Consent.self])
Copied!

Objective-C

Use the AEPMobileCore API to register the Edge Consent extension.
Syntax
1
+ (void) registerExtensions: (NSArray<Class*>* _Nonnull) extensions
2
completion: (void (^ _Nullable)(void)) completion;
Copied!
Example
1
@import AEPEdgeConsent;
2
3
...
4
[AEPMobileCore registerExtensions:@[AEPMobileEdgeConsent.class] completion:nil];
Copied!

updateConsents

Merges the existing consents with the given consents. Duplicate keys will take the value of those passed in the API.
Android
iOS (AEP 3.x)

Java

Syntax
1
public static void update(final Map<String, Object> consents);
Copied!
Example
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!
Example
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
+ (void) updateWithConsents:(NSDictionary<NSString *,id> * _Nonnull)
Copied!
Example
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": collectConsent}];
Copied!
Export as PDF
Copy link
Edit on GitHub