Audience Manager API reference

extensionVersion

The extensionVersion() API returns the version of the Audience extension that is registered with the Mobile Core extension.
To get the version of the Audience extension, use the following code sample:
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin

Java

Example
1
String audienceExtensionVersion = Audience.extensionVersion();
Copied!

Swift

Example
1
let audienceExtensionVersion = Audience.extensionVersion()
Copied!

Objective-C

Example
1
NSString *audienceExtensionVersion = [AEPMobileAudience extensionVersion];
Copied!

Objective-C

Example
1
NSString *audienceExtensionVersion = [ACPAudience extensionVersion];
Copied!

Swift

Example
1
let audienceExtensionVersion = ACPAudience.extensionVersion()
Copied!

JavaScript

Example
1
ACPAudience.extensionVersion().then(audienceExtensionVersion => console.log("AdobeExperienceSDK: ACPAudience version: " + audienceExtensionVersion));
Copied!

Dart

Example
1
String audienceExtensionVersion = await FlutterACPAudience.extensionVersion;
Copied!

Cordova

Example
1
ACPAudience.extensionVersion(function(version) {
2
console.log("ACPAudience version: " + version);
3
}, function(error) {
4
console.log(error);
5
});
Copied!

C#

Example
1
string audienceExtensionVersion = ACPAudience.ExtensionVersion();
Copied!

C#

Example
1
string audienceExtensionVersion = ACPAudience.ExtensionVersion();
Copied!

getVisitorProfile

This API returns the most recently obtained visitor profile. The visitor profile is saved in the SDK's local storage for access across multiple launches of your app. If no audience signal has been sent before, when this API is called, a null value is returned.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
This API returns the most recently obtained visitor profile. For easy access across multiple launches of your app, the visitor profile is saved in SharedPreferences. If no signal has been submitted, null is returned.
When an AdobeCallbackWithError is provided, an AdobeError can be returned in the eventuality of an unexpected error or if the default timeout (5000ms) is met before the callback is returned with the visitor profile.

Java

Syntax
1
public static void getVisitorProfile(final AdobeCallback<Map<String, String>> adobeCallback)
Copied!
Example
1
AdobeCallback<Map<String, String>> visitorProfileCallback = new AdobeCallback<Map<String, String>>() {
2
@Override
3
public void call(final Map<String, String> visitorProfile) {
4
// your own customized code
5
}
6
};
7
8
Audience.getVisitorProfile(visitorProfileCallback);
Copied!
This API returns the most recently obtained visitor profile.

Swift

Syntax
1
static func getVisitorProfile(completion: @escaping ([String: String]?, Error?) -> Void)
Copied!
Example
1
Audience.getVisitorProfile { (visitorProfile, error) in
2
if error != nil {
3
// handle the error here
4
} else {
5
// handle the retrieved visitorProfile here
6
}
7
}
Copied!

Objective-C

Example
1
[AEPMobileAudience getVisitorProfile:^(NSDictionary<NSString *,NSString *> * _Nullable visitorProfile, NSError * _Nullable error) {
2
if (error) {
3
// handle the error here
4
} else {
5
// handle the returned visitorProfile dictionary here
6
}
7
}];
Copied!
The getVisitorProfile API returns the most recently obtained visitor profile. For easy access across multiple launches of your app, the visitor profile is saved in NSUserDefaults. If no signal has been submitted, nil is returned.
The getVisitorProfileWithCompletionHandler method was added in ACPAudience version 2.1.0.

Objective-C

Syntax
1
+ (void) getVisitorProfile: (nonnull void (^) (NSDictionary* __nullable visitorProfile)) callback;
2
3
+ (void) getVisitorProfileWithCompletionHandler: (nonnull void (^) (NSDictionary* __nullable visitorProfile, NSError* __nullable error)) completionHandler;
Copied!
Example
1
[ACPAudience getVisitorProfile:^(NSDictionary* visitorProfile){
2
// handle the visitorProfile here
3
}];
4
5
[ACPAudience getVisitorProfileWithCompletionHandler:^(NSDictionary * _Nullable visitorProfile, NSError * _Nullable error) {
6
if (error) {
7
// handle error here
8
} else {
9
// handle the returned visitorProfile here
10
}
11
}];
Copied!

Swift

Example
1
ACPAudience.getVisitorProfile { (visitorProfile) in
2
// handle the visitorProfile here
3
}
4
5
ACPAudience.getVisitorProfile { (visitorProfile, error) in
6
if let error = error {
7
// handle error here
8
} else {
9
// handle the returned visitorProfile here
10
}
11
}
Copied!

JavaScript

Example
1
ACPAudience.getVisitorProfile().then(profile => console.log("AdobeExperienceSDK: Visitor Profile: " + profile));
Copied!

registerExtension

This API registers an extension class that was derived from ACPExtension with a unique name. This call validates the parameters to ensure that the name is not empty, the name is unique, and that the parent class is ACPExtension.
Android
iOS
React Native

Java

Syntax
1
public static void registerExtension() throws InvalidInitException
Copied!
Example
1
Audience.registerExtension();
Copied!

Objective-C

Syntax
1
+ (BOOL) registerExtension: (nonnull Class) extensionClass
2
error: (NSError* _Nullable* _Nullable) error;
Copied!
Example
1
[ACPAudience registerExtension];
Copied!

Swift

Example
1
ACPAudience.registerExtension()
Copied!

JavaScript

Example
1
ACPAudience.registerExtension();
Copied!

reset

This API helps you reset the Audience Manager UUID and purges the current visitor profile.
For more information about the UUID, the DPID, the DPUUID and other Audience Manager identifiers, see Index of IDs in Audience Manager.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
This API resets the Audience Manager UUID and purges the current visitor profile from android.content.SharedPreferences. The Audience reset also clears the current in-memory DPID and DPUUID variables.

Java

Syntax
1
public static void reset()
Copied!
Example
1
Audience.reset();
Copied!
This API resets the Audience Manager UUID and purges the current visitor profile from UserDefaults. The Audience reset also clears the current in-memory DPID and DPUUID variables.

Swift

Syntax
1
static func reset()
Copied!
Example
1
Audience.reset()
Copied!

Objective-C

Example
1
[AEPMobileAudience reset];
Copied!
The reset API resets the Audience Manager UUID and purges the current visitor profile from UserDefaults. The Audience reset also clears the current in-memory DPID and DPUUID variables.

Objective-C

Syntax
1
+ (void) reset;
Copied!
Example
1
[ACPAudience reset];
Copied!

Swift

Syntax
1
+ (void) reset;
Copied!
Example
1
ACPAudience.reset()
Copied!

JavaScript

Example
1
ACPAudience.reset();
Copied!

signalWithData

This method is used to send a signal with traits to Audience Manager and get the matching segments returned in a block callback. Audience Manager sends the UUID in response to an initial signal call. The UUID is persisted on local SDK storage and is sent by the SDK to Audience Manager in all subsequent signal requests.
If you are using the Experience Cloud ID (ECID) Service (formerly MCID), the ECID and other custom identifiers for the same visitor are sent with each signal request. The visitor profile that is returned by Audience Manager is saved in SDK local storage and is updated with subsequent signal calls.
For more information about the UUID and other Audience Manager identifiers, see the index of IDs in Audience Manager.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
The signalWithData API sends Audience Manager a signal with traits and returns the matching segments for the visitor in a callback.
Audience Manager sends the AAM UUID in response in initial signal call. The AAM UUID is persisted in SharedPreferences and is sent by the SDK in all subsequent signal requests. If available, the ECID is also sent in each signal request with the DPID and the DPUUID. The visitor profile that Audience Manager returns is saved in SharedPreferences and is updated with every signal call.
When an AdobeCallbackWithError is provided, an AdobeError can be returned in the eventuality of an unexpected error or if the default timeout (5000ms) is met before the callback is returned with the visitor profile.

Java

Syntax
1
public static void signalWithData(final Map<String, String> data, final AdobeCallback<Map<String, String>> callback)
Copied!
    data is the traits data for the current visitor.
    callback is the void method that is invoked with the visitor's profile as a parameter.
Example
1
AdobeCallback<Map<String, String>> visitorProfileCallback = new AdobeCallback<Map<String, String>>() {
2
@Override
3
public void call(final Map<String, String> visitorProfile) {
4
// handle the returned visitorProfile here
5
}
6
};
7
8
Map<String, String> traits = new HashMap<String, String>();
9
traits.put("trait", "xyz");
10
Audience.signalWithData(traits, visitorProfileCallback);
Copied!
The signalWithData API sends Audience Manager a signal with traits and returns the matching segments for the visitor in a closure.
Audience Manager sends the AAM UUID in response in initial signal call. The AAM UUID is persisted in NSUserDefaults and is sent by the SDK in all subsequent signal requests. If available, the Experience Cloud ID (MID) is also sent in each signal request with the DPID and the DPUUID. The visitor profile that Audience Manager returns is saved in NSUserDefaults and is updated with every signal call.

Swift

Syntax
1
static func signalWithData(data: [String: String], completion: @escaping ([String: String]?, Error?) -> Void)
Copied!
    data is the traits data for the current visitor.
    callback is the void method that is invoked with the visitor's profile as a parameter.
Example
1
Audience.signalWithData(data: ["trait": "trait value"]) { (traits, error) in
2
if error != nil {
3
// handle the error here
4
} else {
5
// handle the returned visitorProfile here
6
}
7
}
Copied!

Objective-C

Example
1
NSDictionary *traits = @{@"key1":@"value1",@"key2":@"value2"};
2
[AEPMobileAudience signalWithData:traits completion:^(NSDictionary<NSString *,NSString *> * _Nullable visitorProfile, NSError* _Nullable error) {
3
if (error) {
4
// handle the error here
5
} else {
6
// handle the returned visitorProfile dictionary here
7
}
8
}];
Copied!
The signalWithData API sends Audience Manager a signal with traits and returns the matching segments for the visitor in a callback.
Audience Manager sends the AAM UUID in response in initial signal call. The AAM UUID is persisted in NSUserDefaults and is sent by the SDK in all subsequent signal requests. If available, the Experience Cloud ID (MID) is also sent in each signal request with the DPID and the DPUUID. The visitor profile that Audience Manager returns is saved in NSUserDefaults and is updated with every signal call.
The signalWithData:withCompletionHandler method was added in ACPAudience version 2.1.0.

Objective-C

Syntax
1
+ (void) signalWithData: (NSDictionary<NSString*, NSString*>* __nullable) data
2
callback: (nullable void (^) (NSDictionary* __nullable visitorProfile)) callback;
3
4
+ (void) signalWithData: (NSDictionary<NSString*, NSString*>* __nullable) data
5
withCompletionHandler:: (nullable void (^) (NSDictionary* __nullable visitorProfile, NSError* __nullable error)) completionHandler;
Copied!
    data is the traits data for the current visitor.
    callback is the void method that is invoked with the visitor's profile as a parameter.
Example
1
NSDictionary *traits = @{@"key1":@"value1",@"key2":@"value2"};
2
[ACPAudience signalWithData:traits callback:^(NSDictionary* _Nullable visitorProfile){
3
// handle the returned visitorProfile dictionary here
4
}];
5
6
[ACPAudience signalWithData:traits withCompletionHandler:^(NSDictionary * _Nullable visitorProfile, NSError * _Nullable error) {
7
if (error) {
8
// handle the error here
9
} else {
10
// handle the returned visitorProfile dictionary here
11
}
12
}];
Copied!

Swift

Example
1
ACPAudience.signal(withData: ["key1": "value1", "key2": "value2"], callback: { (visitorProfile) in
2
// handle the visitorProfile here
3
})
4
5
ACPAudience.signal(withData: ["key1": "value1", "key2": "value2"], withCompletionHandler: { (visitorProfile, error) in
6
if let error = error {
7
// handle error
8
} else {
9
// handle the returned visitorProfile here
10
}
11
})
Copied!

JavaScript

Example
1
ACPAudience.signalWithData({"yourDataKey": "yourDataValue"}).then(profile => console.log("AdobeExperienceSDK: Visitor Profile: " + profile));
Copied!
Last modified 1mo ago