Google CMP

Handle consent using Google User Messaging Platform

Requirements

<key>GADApplicationIdentifier</key>
<string>YOUR-APP-ID</string>
  • Add the GoogleCMP dependency to your Podfile:

pod 'AATKit/GoogleCMP'

Make sure, your Google 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. We also recommend that CMP should be geographically targeted to "Everywhere", for handling of opt-out consent scenarios. Please also refer to your Google CMP’s documentation.

Usage

Follow the instructions in the Managed Consent introduction section.

  • Create an instance of AATCMPGoogle (AATCMPGoogle conforms to AATCMPProtocol).

  • Pass the created AATCMPGoogle instance while initializing the AATManagedConsent using the public init?(cmp: AATCMPProtocol?, delegate: AATManagedConsentDelegate) method.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    ...
    func configureAATKit() {
        let configuration = AATConfiguration()
        configuration.delegate = self
        let cmp = AATCMPGoogle()
        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.
        // Reload the CMP using the root view controller
        managedConsent.reload(<ROOT VIEW CONTROLLER>)
    }

    func managedConsentCMPFailedToShow(_ managedConsent: AATManagedConsent, with error: String) {
        // CMP failed to show with the error message
    }
}

Last updated