SFBX (AppConsent) CMP
Handle consent using SFBX AppConsent platform
Requirements
Integrate SFBX (AppConsent):
Cocoapods:
Add
pod 'AATKit/AppConsentCMP'to your Podfile.
Swift Package Manager:
Follow the same SPM steps here.
Repeat the last step, and add
AATKit-AppConsentCMP.

Make sure, your SFBX CMP has been set up at its backend dashboard. Please also refer to your SFBX AppConsent documentation.
Usage
Follow the instructions in the Managed Consent introduction section.
Create an instance of
AATCMPAppConsent.Pass the created
AATCMPApinstance while initializing the AATManagedConsent using thepublic init?(cmp: AATCMPProtocol?, delegate: AATManagedConsentDelegate)method.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
func configureAATKit() {
let configuration = AATConfiguration()
configuration.delegate = self
let cmp = AATCMPAppConsent(appKey: "<YOUR_APP_KEY>", forceGDPR: <FORCE_GDPR>, fullscreen: <FULLSCREEN>)
var consent = AATManagedConsent(cmp: cmp, delegate: self)
configuration.consent = consent
AATSDK.initAATKit(with: configuration)
consent?.showIfNeeded(<ROOT VIEW CONTROLLER>)
OR
consent?.showIfNeededOrRejected(daysAgo: 1, viewController: <ROOT VIEW CONTROLLER>)
}
...
}
// MARK: - AATManagedConsentDelegate
extension AppDelegate: AATManagedConsentDelegate {
func managedConsentNeedsUserInterface(_ managedConsent: AATManagedConsent) {
// CMP is loaded and ready to be shown
// Show the CMP using the root view controller
managedConsent.showIfNeeded(<ROOT VIEW CONTROLLER>)
}
func managedConsentCMPFinished(with state: AATManagedConsentState) {
// The user finished his action with CMP with the state as the user chosen state
}
func managedConsentCMPFailedToLoad(_ managedConsent: AATManagedConsent, with error: String) {
// CMP failed to load with the error message.
// Consider reloading the CMP using the active view controller:
// managedConsent.reload(<ROOT VIEW CONTROLLER>)
// if you know that the user is in GDPR region
}
func managedConsentCMPFailedToShow(_ managedConsent: AATManagedConsent, with error: String) {
// CMP failed to show with the error message
}
}@implementation AppDelegate
...
- (void)configureAATKit {
AATConfiguration *configuration = [[AATConfiguration alloc] init];
configuration.delegate = self;
AATCMPAppConsent *cmp = [[AATCMPAppConsent alloc] initWithAppKey:@"YOUR_APP_KEY" forceGDPR:<FORCE_GDPR> fullscreen:<FULLSCREEN>];
AATManagedConsent *consent = [[AATManagedConsent alloc] initWithCmp:cmp delegate:self];
configuration.consent = consent;
[AATSDK initAATKitWith:configuration];
[consent showIfNeeded:<ROOT VIEW CONTROLLER>];
OR
[self.consent showIfNeededOrRejectedWithDaysAgo:1 viewController:<ROOT VIEW CONTROLLER>];
}
...
#pragma mark - AATManagedConsentDelegate
- (void)managedConsentNeedsUserInterface:(AATManagedConsent * _Nonnull)managedConsent {
// CMP is loaded and ready to be shown
// Get the rootViewController
[managedConsent showIfNeeded:<ROOT VIEW CONTROLLER>];
}
- (void)managedConsentCMPFinishedWith:(enum AATManagedConsentState)state {
// The user finished his action with CMP with the state as the user chosen state
}
- (void)managedConsentCMPFailedToLoad:(AATManagedConsent * _Nonnull)managedConsent with:(NSString * _Nonnull)error {
// CMP failed to load with the error message.
// Consider reloading the CMP using the active view controller:
// [managedConsent reload:<ROOT VIEW CONTROLLER>];
// if you know that the user is in GDPR region
}
- (void)managedConsentCMPFailedToShow:(AATManagedConsent * _Nonnull)managedConsent with:(NSString * _Nonnull)error {
// CMP failed to show with the error message
}
@endLast updated