How to integrate UniConsent CMP SDK for iOS with mobile apps

UniConsent CMP is a package for handling GDPR IAB TCF 2.2 consent management in IOS. You can find a demo app integrated with UniConsent CMP in the "uniconsent_demo" directory.

Prerequisites

  • UniConsent CMP plan with Mobile app support
  • iOS >= 14.0
  • UniConsent CMP SDK package (request from support)

Getting started

Add UniConsent.framework into your project, make sure it is Embed & Sign.

Usage

To use the UniConsent CMP in your app, follow these steps:

Initialize the CMP with an App ID from your account manager:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Init CMP with appId
    UniConsent.shared.initialize(apiId: "YOUR_APP_ID_CHANGE_THIS")
    return true
}

Display the CMP UI:

// Display CMP UI
UniConsent.shared.setUIStage(.GDPRFirstScreen)
UniConsent.shared.launchCMP(rootVC: self)

Automatically check if consent is expired when the vendorList updates:

// Automatic check if consent is expired when vendorList updates
UniConsent.shared.shouldRequestConsent()

Get the tcString if required:

// Get tcString if requried
UniConsent.shared.getTCString()

Read the consent status:

// Read consent status
UniConsent.shared.isAllowPurposeById(purposeId: 1)

Reset consent status if required:

// Reset consent status if required:
UniConsent.shared.clearConsentData();

Notes

  1. Users should have the ability to access a "Privacy Settings" button or link in the settings section of your application in order to open the CMP UI.
  2. You can utilize the shouldRequestConsent() function to check whether you should request new consent based on the status. Display the CMP UI as needed when a user opens the application.