# Sourcepoint CMP

### Requirements <a href="#requirements" id="requirements"></a>

Integrate SourcePointCMP:

* Cocoapods:
  * Add `pod 'AATKit/SourcePoint'` to your Podfile.
* Swift Package Manager:

  * Follow the same SPM steps [here](https://aatkit.gitbook.io/ios-integration/start/setup/swift-package-manager).
  * Repeat the last step, and add `AATKit-SourcePointCMP`.

  <figure><img src="https://3006681101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC07HayBzqyav5R2yFhOr%2Fuploads%2FNWpZEXG3V9gd5qdw9Cux%2FScreenshot%202025-04-17%20at%2011.29.10%E2%80%AFAM.png?alt=media&#x26;token=ae71eb6e-407a-4929-8e52-90e49c2ac9a8" alt=""><figcaption></figcaption></figure>

Make sure, your Sourcepoint CMP has been set up at its backend dashboard. Our support recommends certain vendors to be included in your server-side setup in order to yield optimal revenues. Please also refer to your [SourcePoint CMP documentation](https://github.com/SourcePointUSA/ios-cmp-app).

### Usage

Follow the instructions in the Managed Consent [introduction section](https://aatkit.gitbook.io/ios-integration/start/consent/managed-consent/..#introduction).

* Create an instance of AATCMPSourcepoint.
* Pass the created AATCMPSourcepoint instance while initializing the AATManagedConsent using the `public init?(cmp: AATCMPProtocol?, delegate: AATManagedConsentDelegate)` method.

{% tabs %}
{% tab title="Swift" %}

```swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    ...
    func configureAATKit() {
        let configuration = AATConfiguration()
        configuration.delegate = self
        let cmp = AATCMPSourcepoint(accountId: "accountId", propertyId: "propertyId", propertyName: "propertyName", pmId: "pmId") 
        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
    }
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
@implementation AppDelegate
...
- (void)configureAATKit {
    AATConfiguration *configuration = [[AATConfiguration alloc] init];
    configuration.delegate = self;
    AATCMPSourcepoint *cmp = [[AATCMPSourcepoint alloc]initWithAccountId:@"accountId" propertyId:@"propertyId" propertyName:@"propertyName" pmId:@"pmId"];
    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
}
@end
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aatkit.gitbook.io/ios-integration/start/consent/managed-consent/sourcepoint-cmp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
