SmartCMP for iOS is a iOS framework allowing you to retrieve and store the user's consent for data usage in your iOS apps.
The purposes & vendors retrieval as well as the consent storage is compliant with IAB Transparency and Consent Framework specifications.
Retrieving user consent is mandatory in EU starting May 25th due to the General Data Protection Regulation (GDPR).
Import the pod SmartCMP in your project by adding to your Podspec file:
pod 'SmartCMP'
Then run pod update
to install SmartCMP.
Download this repository, drag the SmartCMP.xcodeproj
from the framework directory to your Xcode project and add the SmartCMP.framework
target to the Embedded Binaries section of your project General properties.
The CMP must be imported before being used:
import SmartCMP
Note: if your app is developed in Objective-C, you can import the CMP using:
#import <SmartCMP/SmartCMP-Swift.h>
You must setup the CMP before using it. Start by creating a configuration object that will define how the first screen of the consent tool will look like:
let config = CMPConsentToolConfiguration(logo: UIImage(named: "logo")!,
homeScreenText: "[Place here your legal privacy notice for the consent tool, compliant with GDPR]",
homeScreenManageConsentButtonTitle: "MANAGE MY CHOICES",
homeScreenCloseButtonTitle: "GOT IT, THANKS!",
consentManagementScreenTitle: "Privacy preferences",
consentManagementCancelButtonTitle: "Cancel",
consentManagementSaveButtonTitle: "Save",
consentManagementScreenVendorsSectionHeaderText: "Vendors",
consentManagementScreenPurposesSectionHeaderText: "Purposes",
consentManagementVendorsControllerAccessText: "Authorized vendors",
consentManagementActivatedText: "yes",
consentManagementDeactivatedText: "no",
consentManagementPurposeDetailTitle: "Purpose",
consentManagementPurposeDetailAllowText: "Allowed",
consentManagementVendorDetailViewPolicyText: "View privacy policy",
consentManagementVendorDetailPurposesText: "Required purposes",
consentManagementVendorDetailLegitimatePurposesText: "Legitimate interest purposes",
consentManagementVendorDetailFeaturesText: "Features")
Call the configure()
method on CMPConsentManager.shared
to start the CMP.
CMPConsentManager.shared.configure(language: CMPLanguage.DEFAULT_LANGUAGE, consentToolConfiguration: self.generateConsentToolConfiguration())
When the CMP is started, it will automatically fetch the most recent vendors list (vendors.json) and prompt the user for consent if necessary, saving the resulting consent string in iOS NSUserDefaults (according to the IAB specifications).
You might want to control when the user will be prompted for consent for better user experience. In this case, define a delegate for CMPConsentManager.shared
:
CMPConsentManager.shared.delegate = self
When retrieval of the user consent is required, the consentManagerRequestsToShowConsentTool
method will be called on the delegate and it will be the app's responsability to display the consent tool UI when appropriate.
func consentManagerRequestsToShowConsentTool(_ consentManager: CMPConsentManager, forVendorList vendorList: CMPVendorList) {
// It is necessary to update the user consent using the consent tool or your own UI
}
Showing the consent tool is done using the method showConsentTool
. Note that this method can be used not only when it has been requested by the consent manager, but also anytime you want to provide a way for the user to change its consent options.
CMPConsentManager.shared.showConsentTool(fromController: self)
On iOS, the user can opt out for any tracking related to advertisement by enabling 'Limited Ad Tracking' in the OS settings. By default, the CMP does not handle this option and let the app developer choose how he wants to proceed if it has been enabled by the user. Please note that not handling the 'Limited Ad Tracking' option properly is a violation of Apple App Store's terms & conditions. Your app might be removed from the store.
However, if you configure the CMP with the parameter showConsentToolWhenLimitedAdTracking
set to false, it will handle the 'Limited Ad Tracking' option automatically. In case of limited ad tracking the CMP will not display the consent tool and will not call the delegate, but will instead store a consent string with no consent given for any purposes or vendors.
The current version of SmartCMP has the following limitations:
- The consent tool UI is not customizable (except for static texts). You can however build your own UI and display it in the
consentManagerRequestsToShowConsentTool
delegate method using thevendorList
parameter. - AppleTV apps are not supported.
- The IAB specification allows publishers to display only a subset of purposes & vendors using a pubvendors.json file, stored on their own infrastructure. SmartCMP does not implement this feature at this time.
- No static texts are provided by default (you must provide them to
CMPConsentToolConfiguration
). ThehomeScreenText
should be validated by your legal department. - SmartCMP does not have any logic to know if GDPR applies or not based on user's location / age at this time. For the moment it is the publisher's responsibility to determine whether or not GDPR applies and if the consent tool UI should be shown to the user, as well as requesting permission to fetch location or other including / excluding criteria.
This software is distributed under the Creative Commons Legal Code, Attribution 3.0 Unported license.
Check the LICENSE file for more details.
The CMP ID '33' used for consent string encoding is the CMP ID of Smart AdServer.
You can use this CMP ID as long as you don't alter the source code of SmartCMP. If you do modify the source code, YOU MUST REGISTER YOUR FORK AS A NEW CMP and change the CMP ID in CMPConstants.CMPInfos.ID
. You can register your forked CMP and obtain your own ID here: https://register.consensu.org/CMP