The extensionVersion() API returns the version of the client-side Consent extension.
{% tabs %} {% tab title="Android" %}
Syntax
public static String extensionVersion();
Example
String extensionVersion = Consent.extensionVersion();
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Syntax
static var extensionVersion: String
Example
let extensionVersion = Consent.extensionVersion
Syntax
+ (nonnull NSString*) extensionVersion;
Example
NSString *extensionVersion = [AEPMobileEdgeConsent extensionVersion];
{% endtab %} {% endtabs %}
Retrieves the current consent preferences stored in the Consent extension.
{% tabs %} {% tab title="Android" %}
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, 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
Consent.getConsents(new AdobeCallback<Map<String, Object>>() {
@Override
public void call(Map<String, Object> currentConsents) {
// handle currentConsents
}
});
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
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
}
Syntax
+ (void) getConsents:^ (NSDictionary<NSString *,id> * _Nullable, NSError * _Nullable)
Example
[AEPMobileEdgeConsent getConsents:^(NSDictionary *currentConsents, NSError *error){
// handle currentConsents
}];
{% endtab %} {% endtabs %}
Registers the Edge Consent extension with the Mobile Core SDK.
{% tabs %} {% tab title="Android" %}
Syntax
public static void registerExtension();
Example
Consent.registerExtension();
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Use the MobileCore API to register the Edge Consent extension.
Syntax
static func registerExtensions(_ extensions: [NSObject.Type],
_ completion: (() -> Void)? = nil)
Example
import AEPEdgeConsent
...
MobileCore.registerExtensions([Consent.self])
Use the AEPMobileCore API to register the Edge Consent extension.
Syntax
+ (void) registerExtensions: (NSArray<Class*>* _Nonnull) extensions
completion: (void (^ _Nullable)(void)) completion;
Example
@import AEPEdgeConsent;
...
[AEPMobileCore registerExtensions:@[AEPMobileEdgeConsent.class] completion:nil];
{% endtab %} {% endtabs %}
Merges the existing consents with the given consents. Duplicate keys will take the value of those passed in the API.
{% tabs %} {% tab title="Android" %}
Syntax
public static void update(final Map<String, Object> consents);
- consents - A
Map
of consents defined based on Privacy/Personalization/Marketing Preferences (Consents) XDM Schema.
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);
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Syntax
static func update(with consents: [String: Any])
- consents - A
[String: Any]
of consents defined based on Privacy/Personalization/Marketing Preferences (Consents) XDM Schema.
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)
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}];
{% endtab %} {% endtabs %}