MAdvertiseCMP

MAdvertise's CMP - Compliant with IAB Transparency and Consent Framework and Consent String and Vendor List v1.1 specifications


Licenses
CC0-1.0/NTP-0
Install
pod try MAdvertiseCMP

Documentation

MAdvertiseCMP

[TOC]

First you will need to add the framework to you project:

Using Cocoapods:

The MAdvertiseCMP framework is available through Cocoapods. see Using CocoaPods section.

Manually :

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) :

  • ConsentToolText: represent the main text that will be displayed once the consent tool (popup) is shown.
  • ConsentToolTitle: represent the title of the consent tool.
  • ConsentToolAcceptButtonTitle: represent the title of the consent tool accept all button.
  • ConsentToolSettingsButtonTitle: represent the title of the consent tool button that will that the user to the management screen.
  • ConsentToolBackgroundColor
  • ConsentManagementCancelButtonTitle
  • ConsentManagementAcceptAllButtonTitle
  • ConsentManagementPublisherName
  • ConsentManagementVendorsButtonTitle
  • ConsentManagementSaveButtonTitle
  • ConsentManagementTitle
  • authorizedVendors: array of ids of authorized vendors (empty by default which will include all vendors)
  • VendorHeaderTitle
  • vendorListSorted: Boolean to indicate wether you want the vendor list to be sorted alphabetically or not
  • consentManagementStoredData
  • dataManagementTitle
  • dataManagementSubtitle
  • dataManagementDataAccess
  • dataManagementDataAccessDescription
  • dataManagementRectifyData
  • dataManagementRectifyDataDescriptionOne
  • dataManagementRectifyDataDescriptionTwo
  • dataManagementRectifyDataEmailHint
  • dataManagementRequestInformation
  • dataManagementOptOut
  • dataManagementOptInDescription
  • dataManagementRequestDeletion
  • dataManagementRequestInformationMessage
  • dataManagementOptoutMessage
  • dataManagementSubmissionError
  • dataManagementSubmissionError
  • invalidEmailError
  • appId (optional APP_ID provided by Madvertise team when Your are using Madvertise SDK for adserving. In this case we display "data access and deletion menu" for Madvertise Adserving data)
  • consentToolColorPalette { // customize the regular consentTool colors
    • primaryBackground
    • secondaryBackground
    • primaryText
    • secondaryText }
  • consentToolWithLocationColorPalette { // customize the consentTool with location colors
    • primaryBackground
    • secondaryBackground
    • primaryText
    • secondaryText }

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")
}

Objective-c

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>

  • the current version of the framework doesnt support bitcode, so when archiving your app you will need to disable bitcode.

data access and deletion menu:

You must add madvertise APP_ID on consent settings file (plist) in order to display "data access and deletion" menu for Madvertise Adserving data)

MAdvertiseCMP With Location:

#####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
integration

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 .
     }