-
Add the library to your project via your
Podfileby adding:pod 'ACPAudience' -
Import the Audience and Identity library:
#import <ACPCore_iOS/ACPCore_iOS.h> #import <ACPAudience_iOS/ACPAudience_iOS.h> #import <ACPIdentity_iOS/ACPIdentity_iOS.h>
Important: Audience Manager depends on the Identity extension and is automatically included in the Core pod. When installing manually, ensure that you have also added the
ACPIdentity.frameworkto your project. -
Register both the Audience and Identity extensions in your app's
didFinishLaunchingWithOptionsfunction.- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [ACPIdentity registerExtension]; [ACPAudience registerExtension]; // Override point for customization after application launch. return YES; }
Returns the visitor profile that was most recently obtained.
The visitor profile is saved in NSUserDefaults for easy access across multiple launches of your app. If no signal has been submitted, nil is returned.
+ (void) getVisitorProfile: (nonnull void (^) (NSDictionary* __nullable visitorProfile)) callback;[ACPAudience getVisitorProfile:^(NSDictionary* visitorProfile){
// your customized code
}];Resets the Audience Manager UUID, purges the current visitor profile from NSUserDefaults, reset, and clears the current in-memory DPID and DPUUID variables.
+ (void) reset;[ACPAudience reset];Sends Audience Manager a signal with traits and returns the matching segments for the visitor in a callback.
Audience manager sends an AAM UUID in a response to the initial signal call. AAM UUID is persisted in NSUserDefaults and sent by the SDK in all subsequent signal requests. If available, an Experience Cloud ID (ECID) is also sent in each signal request with the DPID and DPUUID. The visitor profile that AAM returns is saved in NSUserDefaults and is updated with every signal call.
+ (void) signalWithData: (NSDictionary<NSString*, NSString*>* __nullable) data
callback: (nullable void (^) (NSDictionary* __nullable visitorProfile)) callback;NSDictionary *traits = @{@"key1":@"value1",@"key2":@"value2"};
[ACPAudience signalWithData:traits callback:^(NSDictionary* visitorProfile){
// your customized code
}];