Swift library to help you add GDPR functionality to your app
Clone or download
Cristian Baluta
Cristian Baluta Separate DataSource
Latest commit e196c4c Jun 8, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo-ios Separate DataSource Jun 8, 2018
src Separate DataSource Jun 8, 2018
Consent.podspec First commit May 21, 2018
LICENSE Initial commit May 21, 2018
README.md Alert when turning a switch on becomes optional, you can control that… Jun 4, 2018



Note: This library only helps you collect consents for the services in your app, actually disabling those services is developer's job.



Define the services in your app

Note: Some generic services can be found in ConsentKitServices

enum Services: String, ConsentKitItem {

        case icloud = "iCloud"
        case analytics = "analytics"

        func title() -> String {
            switch self {
                case .icloud: return "iCloud"
                case .analytics: return "Google analytics"
        func description() -> String {
            switch self {
                case .icloud: return "Wether to accept iCloud or not"
                case .analytics: return "Google analytics"
        func alertMessage() -> String? {
            switch self {
                case .icloud: return nil
                case .analytics: return "I accept this app to store anonymous analytics in Google Analytics!"

Instantiate the lib, preferably once in the AppDelegate, but can be anywhere and as many times as you like.

let gdpr = ConsentKit()

Check if you have missing consents

If yes, add the default ConsentKitViewController to handle all the switches for you.

if gdpr.needsReviewing([Services.icloud, Services.analytics]) {

    let vc = ConsentKitViewController()
    vc.items = [Services.icloud, Services.analytics, ConsentKitServices.location]
    self.present(vc, animated: true)

Custom storage

By default ConsentKit keeps values in UserDefaults, but you can change that with the gdpr.dataSource property. Just assign or pass through constructor a class implementing the ConsentKitDataSource

let gdpr = ConsentKit(dataSource: InMemoryDataSource())// InMemoryDataSource implements ConsentKitDataSource

protocol ConsentKitDataSource {
    func isAccepted (_ item: ConsentKitItem) -> Bool
    func isReviewed (_ item: ConsentKitItem) -> Bool
    func setAccepted (_ value: Bool, for item: ConsentKitItem)
    func reset (_ item: ConsentKitItem)// Optional


Help me create a complete list of services that the developers can use. Thanks.