Consent Manager

1. Choose your type of installation


1.Add following line into your Podfile

pod 'StackConsentManager', '~> 1.1.0'

2.Run pod install

2. Synchronize 


Consent manager SDK can be synchronized at any moment of application lifecycle. We recommend to synchronize it at application launch. Multiple synchronization calls are allowed.

Import StackConsentManager/StackConsentManager.h in AppDelegate.m

import StackConsentManager
Call synchronise consent in  -application:didFinishLaunchingWithOptions:

Required parameter is appKey - Appodeal API Key. 

Optional parameters are customParameters (string - any dictionary of custom parameters) and completion (block that invokes after synchronization)

/// Initialisation 
class YourAppDelegate: AppDelegate {
    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
        STKConsentManager.shared().synchronize(withAppKey: "Your app key") { [unowned self] error in { print("Error while synchronising consent manager: \($0)") }
			guard STKConsentManager.shared().shouldShowConsentDialog == .true else {
                // Initialise SDK here
			// Load and present consent dialog                                   
        return true

After synchronization completion, you can receive information about the previous user consent and regulation zone. Before synchronization these parameters are undefined

// Check regulation
let regulation = STKConsentManager.shared().regulation
// Check consent status
let status = STKConsentManager.shared().consentStatus
// Available after first show (synchronisation is required)
let consentString = STKConsentManager.shared().iabConsentString


You can force consent manager to write iAB keys in NSUserDefaults by setting up storage property before synchronization to STKConsentDialogStorageUserDefaults

SDK does not remove iAB keys from NSUserDefaults and only overrides them

// Store IAB strings in user defaults
// should be called before synchronize
STKConsentManager.shared().storage = .userDefaults

You can register yourself as a vendor before synchronization. 

idIntegeriAB id. If you are not registered as iAB vendor you can use custom id
nameStringDisplay name. Will be displayed in the consent window
statusString Custom string to check consent result for the concrete vendor
purposesIdsArray of integersiAB purposes ids array
featuresIdsArray of integersiAB features ids array
legIntPurposeIdsArray of integersiAB leg int purposes ids array
// Register custom vendor (will be displayed on consent window)
// should be called before synchronize
STKConsentManager.shared().registerCustomVendor { builder in
	let _ = builder
        .appendPolicyURL(URL(string: "")!)
        .appendName("My app")
        .appendPurposesIds([1, 2, 3])
        .appendFeaturesIds([5, 6])

3. Consent window

SDK allows to call consent window api only after synchronization 

After SDK synchronized, you can load the consent window. Loading allowed in any regulation zone and independent from previous consent.

class YourViewController: UIViewController {
	override func viewDidLoad() {
		STKConsentManager.shared().loadConsentDialog { [unowned self] error in { print("Error while loading consent dialog: \($0)") }
				let controller = self.window?.rootViewController, 
			else {
				// Initialise SDK here
			STKConsentManager.shared().showConsentDialog(fromRootViewController: controller, 
				delegate: self)

You can check that the consent window is ready or not

// Indicates that consent window ready to present
let isReady = STKConsentManager.shared().isConsentDialogReady

After consent window Is ready you can present it from the top view controller

// Show consent dialog
STKConsentManager.shared().showConsentDialog(fromRootViewController: controller, delegate: self)

Handling presentation callbacks

/// Get consent manager presentation callbacks
class YourViewController: UIViewController, STKConsentManagerDisplayDelegate {
	// MARK: STKConsentManagerDisplayDelegate
	func consentManagerWillShowDialog(_ consentManager: STKConsentManager) {}
	func consentManager(_ consentManager: STKConsentManager, didFailToPresent error: Error) {
		// Something went wrong
	func consentManagerDidDismissDialog(_ consentManager: STKConsentManager) {
		// Resume app

4. App Tracking Transparency

App Tracking transparency request is enabled by default for new users with iOS 14.5 or higher. It will be presented after showConsentDialog method call. To use this your need to add AppTrackingTransparency.framework to your project.

And add NSUserTrackingUsageDescription key into your project info.plist file.

<string>This identifier will be used to deliver personalized ads to you.</string>

Because of Consent Manager will show ATT request only for users under iOS 14.5 or higher you might be to add some notes in App Review Information section of app version page in App Store Connect. For example it can be something like: App Tracking Transparency request is only available for users under iOS 14.5 or higher. This step can be needed because Apple can reject builds that contains AppTrackingTransparency.framework but which ATT requests are not showing at app launch.

In case you have your own ATT logic, you can disable it before synchronisation. 

class YourAppDelegate: AppDelegate {
    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
        STKConsentManager.shared().synchronize(withAppKey: "Your app key") { error in
            guard let error = error else { return }
            print("Error occurred during synchronization: \(error)")
        return true

Actual tracking authorisation status can be received by trackingAuthorizationStatus:

switch STKConsentManager.shared().trackingAuthorizationStatus {
	case .restricted: print("Tracking is restricted via device settings")
    case .denied: print("Tracking is denied")
    case .authorized: print("Tracking is allowed")
    default: print("Status is unknown")

5. Appodeal SDK initialisation

func initializeAppodealSDK() {        
	guard let consent = STKConsentManager.shared().consent
	else {
		let consent = STKConsentManager.shared().consentStatus != .nonPersonalized
			withApiKey: AppodealConstants.key,
			types: AppodealConstants.adTypes,
			hasConsent: consent
		withApiKey: AppodealConstants.key, 
		types: AppodealConstants.adTypes,
		consentReport: consent

You can use our demo app as a reference project.

6. Error handling

All returned errors are NSError instances with custom codes:



Error on SDK side. Includes JS-bridge or encoding/decoding errors


HTTP errors
STKConsentManagerErrorInconsistentIncorrect SDK API usage


Any other errors