6 - Integrate with a Consent Management Platform (CMP)
X3M provides a mechanism for automating the integration with Google's User Messaging Platform. To enable this feature, set the flag isCMPAutomationEnabled
to true
:
X3MConsentInformation *consentInformation = [X3MConsentInformation new];
consentInformation.isCMPAutomationEnabled = YES;
X3MInitSettings *initSettings = [X3MInitSettings new];
initSettings.consentInformation = consentInformation;
[X3MXMediatorAds startWithAppKey:@"<your-app-key>"
initSettings:initSettings
callback:^(NSError * _Nullable error) {
// [...]
}];
This will prompt the user for consent only when required, and continue with the SDK initialization after the signals have been collected.
Display a Privacy Settings button inside your app
To give users the option to change their consent during the session, you may want to display a button in your app's settings when a form is available. X3M's SDK provides the following methods to achieve this:
if (XMediatorAds.cmpProvider.isPrivacyFormAvailable()) {
// ... display the privacy settings form button
}
// [...]
XMediatorAds.cmpProvider.presentPrivacyForm(fromViewController: self) { error in
if let error = error {
print("Error: \(error.localizedDescription)")
}
print("presentPrivacyForm complete!")
}
if (X3MXMediatorAds.cmpProvider.isPrivacyFormAvailable) {
// ... display the privacy settings form button
}
// [...]
[X3MXMediatorAds.cmpProvider presentPrivacyFormFromViewController:self onComplete:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Error: %@", error);
}
NSLog(@"presentPrivacyForm complete!");
}];
Debug your integration
When using the CMP Automation feature, you can use the following methods to debug your integration:
// Available options: .disabled, .EEA and .notEEA
let cmpDebugSettings = CMPDebugSettings(debugGeography: .EEA)
let consentInformation = ConsentInformation(isCMPAutomationEnabled: true,
cmpDebugSettings: cmpDebugSettings)
let initSettings = InitSettings(consentInformation: consentInformation)
// Configure a Debug Geography to trigger Privacy Form display
XMediatorAds.startWith(appKey: "<your-app-key>",
initSettings: initSettings) { _ in
// [...]
}
// Clear the collected consent signals from the device (debug only)
XMediatorAds.cmpProvider.reset()
X3MConsentInformation *consentInformation = [X3MConsentInformation new];
consentInformation.isCMPAutomationEnabled = YES;
// Configure a Debug Geography to trigger Privacy Form display
consentInformation.cmpDebugSettings = [[X3MCMPDebugSettings alloc] initWithDebugGeography:X3MCMPDebugGeographyEEA];
X3MInitSettings *initSettings = [X3MInitSettings new];
initSettings.consentInformation = consentInformation;
[X3MXMediatorAds startWithAppKey:@"<your-app-key>"
initSettings:initSettings
callback:^(NSError * _Nullable error) {
// [...]
}];
// Clear the collected consent signals from the device (debug only)
[X3MXMediatorAds.cmpProvider reset];