Consent Manager

1. Choose your type of installation


1.Add following line into your Podfile

pod 'StackConsentManager', '~> 1.0.1'

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

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