MAdvertise's CMP - Compliant with IAB Transparency and Consent Framework and Consent String and Vendor List v1.1 specifications
Homepage CocoaPods Documentation
[TOC]
First you will need to add the framework to you project:
The MAdvertiseCMP framework is available through Cocoapods. see Using CocoaPods section.
download the latest version of MAdvertiseCMP framework, add it to your project and make sure it s included in 'Embedded binaries' in the general tab of your project configuration.
First you ll need to download and configure the consent settings file (plist), which serve to customise the appearance of the consent tool as well as filter the list of vendors by ID (by default all vendors are activated) :
once the consent settings is configured and added to your target, you can then initialise/configure the CMPConsentManager shared instance by providing the name of you consent settings file, eg :
// Configure the CMPConsentManager shared instance.
let cmpLanguage = CMPLanguage(string: "en") ?? CMPLanguage.DEFAULT_LANGUAGE
CMPConsentManager.shared.configure("MAdvertiseCMPSettings_en", language: cmpLanguage, consentToolSize: CGSize(width: 300, height: 600))
now once the the consent manager finishes its setup process it will call on its delegate by invoking the following method to let the publisher know that the manager is ready and he should display the consent tool to the user :
func consentManagerRequestsToShowConsentTool(_ consentManager: CMPConsentManager, forVendorList vendorList: CMPVendorList) {
NSLog("CMP Requested ConsentTool Display");
// You should display the consent tool UI, when user is ready�
// Since the vendor list is provided in parameter of this delegate method, you can also build your own UI to ask for
// user consent and simply save the resulting consent string in the relevant IAB keys (see the IAB specification for
// more details about this).
//
// To generate a valid IAB consent string easily, you can use the CMPConsentString class.
}
once the above delegate is called you should display the consent tool (or use your own) using the following line :
CMPConsentManager.shared.showConsentTool(fromController: viewController)
Also every time the consent string changes its value another callback method of the CMPConsentManagerDelegate delegate will be invoked to inform you of the recent change :
#!objective-c
-(void)consentStringDidChange:(CMPConsentString *)newConsentString {
NSLog(@" Consent String did change : %@", newConsentString.consentString);
}
#!swift
func consentStringDidChange(_ newConsentString: CMPConsentString) {
print("consent string did change")
}
Note as well that some of the users might want to view (review) the publisher's privacy policy, and for that purpose we dedicated another callback method on CMPConsentManager.shared.delegate
func consentManagerRequestsToPresentPrivacyPolicy(){
print("present your privacy policy view")
}
In case you find some kind of issue importing the framework to your objective c classes, you should know that just importing MAdvertiseCMP-Swift.h header will be enough to have the entire framework imported, so wherever you want to use the framework just add this line :
#import <MAdvertiseCMP/MAdvertiseCMP-Swift.h>
You must add madvertise APP_ID on consent settings file (plist) in order to display "data access and deletion" menu for Madvertise Adserving data)
#####Donwload File Configuration
First you'll need to download and configure the consent settings file "MAdvertiseCMPSettings_location_config_fr.plist" . this file has 3 new fields to Geolocation Permission :
key | format | description |
---|---|---|
ConsentManagementPublisherName | String | Application name |
ConsentManagementValidateButtonTitle | String | The text of validation button |
ConsentToolGeoLocationTitle | String | Ads permission title |
ConsentToolGeoLocationDescription | String | Ads permission description |
once the consent settings is configured and added to your target, you can then initialise/configure the CMPConsentManager shared instance by providing the name (MAdvertiseCMPSettings_location_config_fr) of you consent settings file, eg :
// Configure the CMPConsentManager shared instance.
let cmpLanguage = CMPLanguage(string: "en") ?? CMPLanguage.DEFAULT_LANGUAGE
CMPConsentManager.shared.configure("MAdvertiseCMPSettings_location_config_fr", language: cmpLanguage, consentToolSize: CGSize(width: 300, height: 600))
now once the the consent manager finishes its setup process it will call on its delegate by invoking the following method to let the publisher know that the manager is ready and he should display the consent tool Location to the user :
func consentManagerRequestsToShowConsentTool(_ consentManager: CMPConsentManager, forVendorList vendorList: CMPVendorList) {
NSLog("CMP Requested ConsentTool Display");
[consentManager showConsentToolWithLocationFromController:self];
// To generate a valid IAB consent string easily, you can use the CMPConsentString class and IABConsent_LocationPurpose .
}
From version v16 you can display the view ConsentTool location either in pop-up form or in full screen by the bollean attribut withPopup :
func consentManagerRequestsToShowConsentTool(_ consentManager: CMPConsentManager, forVendorList vendorList: CMPVendorList) {
NSLog("CMP Requested ConsentTool Display");
[consentManager showConsentToolWithLocationFromController:self withPopup:YES ];
// To generate a valid IAB consent string easily, you can use the CMPConsentString class and IABConsent_LocationPurpose .
}