iOS

Download AppConsent XCFramework with Kit & UIKit files in it.

XCFramework 1.2.14

Last revision: 01.08.2021

2 ways to add AppConsent SDK to your iOS Project.

Drag & Drop XCFramework

Follow the steps below:

  • In General tab of your application target, drag and drop the AppConsentKit.xcframework and the AppConsentUIKit.xcframework in Frameworks, Libraires and Embedded Content. Make sure the XCFrameworks are Embed & Sign.

  • Compatibility xCode 12 and above. Deployment target iOS 11 minimum.

Cocoapods

Now you can install AppConsent SDK with Cocoapods.

In your podfile add this following pod:

pod 'AppConsentKit', '~> 1.2.0'
pod 'AppConsentUIKit', '~> 1.2.0'

Don’t forget to add on top of your podfile these lines:

source 'https://github.com/CocoaPods/Specs.git'
source 'https://gitlab.datalf.chat/dev/appconsentios-private-pod.git'

Run pod install in your command line.

Note: You need at least 1.10.0 pod version to works fine.

You can find an example below:

Swift Package Manager

Now you can install AppConsent SDK with Swift Package Manager.

Note: At the moment, due to some issues of binary target with XCFramework, sub-dependencies andPackage Manager you need to install all packages manually.

AppConsentKit 1.2.2
https://gitlab.datalf.chat/customers/appconsentkit-spm
AppConsentUIKit
1.2.2
https://gitlab.datalf.chat/customers/appconsentuikit-spm
SwiftProtobuf
1.14.0
https://github.com/apple/swift-protobuf

How to use AppConsent

  1. First get your AppKey from our AppConsent account

  2. You have to import the SDK in your code: import AppConsentUIKit

  3. After that, you can create and initialize ACUIKit like this:

let appconsent = ACUIKit(withAppKey: "YOUR_APP_KEY", forceApplyGDPR: true, forceATT: true)

Important

AppConsent SDK supports the new App Tracking Transparency framework (> iOS 14+ available).You must register the NSUserTrackingUsageDescription key in your Info.plist of your applicationotherwise your app will crash.

App Tracking Transparency

Apple release iOS 14.5 few days ago (26 April 2021).

One of the big changes is the new system popup called App Tracking Transparency (ATT). App Tracking Transparency requires apps to get the user’s permission before tracking their data across apps or websites owned by other companies for advertising, or sharing their data with data brokers. Apps can prompt users for permission, and in Settings, users will be able to see which apps have requested permission to track so they can make changes to their choice at any time.

Our last framework (version 1.2.11 +) is fully compatible and integrated with our Content Management Platform. On the App Consent back-office you must turn to on the switch use iOS Att and turn to on the switch disable success screen (for device below iOS 14).

Don't forget to register the NSUserTrackingUsageDescription key in your Info.plist of your application otherwise your app will crash.

Note: If you did not update your application with the last Framework and if your application works on iOS 14.5 device, the IDFA will be 00000-00000-00000-00000.

Floating Purpose - ATT

On the App Consent back-office, you must create an Extra-Purpose for ATT feature.

Steps: Go to Extra-Purposes menu on the left, and click to Add Extra Purpose on the top-right corner. Enter a name, description and select Floating for Type. Save.

On your Notice, click to Edit and on the configuration section add your new Floating Extra Purpose for ATT. Save.

Features of AppConsentUIKit

appconsent.consentGiven()

Return true if consent is given, false otherwise.

Present notice

appconsent.presentNotice(force: true, viewController: self)

To display the CMP by modal mode on your ViewController.

appconsent.consentGiven(success: {
print("Success - Consent Given")
}, failure: { error in
print("Error: \(error)")
})
appconsent.geolocationConsentGiven()

Return true if consent is given, false otherwise.

appconsent.geolocationConsentGiven(success: {
print("Success - Consent Given")
}, failure: { error in
print("Error: \(error)")
})

Consentable allowed - objectId

appconsent.consentableAllowed(objectId: "1")

Return true if consentable with objectId = 1 is allowed, false otherwise.

Consentable allowed - iabId

appconsent.consentableAllowed(iabId: "1")

Return true if consentable with iabId = 1 is allowed, false otherwise.

Consentable allowed - extraId

appconsent.consentableAllowed(extraId: "1")

Return true if consentable with extraId = 1 is allowed, false otherwise.

Stack allowed

appconsent.stackAllowed(iabId: "1")

Return true if consentable with iabId = 1 is allowed, false otherwise.

Vendor allowed - iabId

appconsent.vendorAllowed(iabId: "1")

Return true if consentable with iabId = 1 is allowed, false otherwise.

Vendor allowed - extraId

appconsent.vendorAllowed(extraId: "1")

Return true if consentable with extraId = 1 is allowed, false otherwise.

All Consentables allowed

appconsent.allConsentablesAllowed()

Return true if all consentables are allowed, false otherwise.

All Stacks allowed

appconsent.allStacksAllowed()

Return true if all stacks are allowed, false otherwise.

All Vendors allowed

appconsent.allVendorsAllowed()

Return true if all vendors are allowed, false otherwise.

User Accept All

appconsent.userAcceptAll()

It's a combination of allConsentablesAllowed , allStacksAllowed, allVendorsAllowed

Return true if all of these are true otherwise false.

appconsent.setConsentableConsents(values: ["1": .allowed], success: {
print("Success")
}, failure: { error in
print("Error: \(error)")
})

Set consentables status with an iabId.

Warning Key must be an iabId, not an objectId.

Note this method doesn’t send request to the server.

appconsent.setExtraConsentableConsents(values: ["aaa": .allowed], success: {
print("Success")
}, failure: { error in
print("Error: \(error)")
})

Set consentbles status with extraId.

Warning Key must be an extraId, not an objectId.

Note this method doesn’t send request to the server.

Check for update

appconsent.checkForUpdate({ value in
print("Success: \(value)")
}, failure: { error in
print("Error: \(error)")
})

Check if consent must be updated (new gvl version, new consentables…)

Clear consents

appconsent.clearConsent()

Clear consents on NSUserDefaults, but not on server.

Set external data

appconsent.setExternalData(shipData: ACShipData, success:, failure:)

Set external data with ACShipData model and send it to server.

Set externalIds

appconsent.setExternalIds(externalIds: [String: String])

You can setExternalIds. Behind the scene, externalIds are stored in our cache Framework. If you want, you can save it to our server like this:

appconsent
.setExternalIds(externalIds: [String: String])
.saveExternalIds { state, configuration in
print(state ?? "state nil")
print(configuration ?? "configuration nil")
} failure: { error in
print(error.localizedDescription)
}

Get externalIds

appconsent.getExternalIds() ->[String, String]

Retrieve the externalIds set before.

Open App Settings

appconsent.openAppSettings()

Open App Consent settings in the general tab.

App Tracking is available

appconsent.appTrackingIsAvailable() ->Bool

Check if your device supports App Tracking Transparency.

App Tracking Authorization

appconsent.appTrackingAuthorizationGiven() ->ACATTAuthorizationGiven

Check if App Tracking Transparency has been given.

App Tracking Request

appconsent.appTrackingRequestAuthorization(_ completion: ((ACATTAuthorizationStatus)->Void)?)

Request user authorization. The ATT popup will be display.

Note: the process to display ATT Popup is automatically integrated in AppConsentUIKit when user save hisconsent

Save ATT floating purpose

appconsent.saveATTFloatingPurpose(with value: Bool, _ completion: ACResultVoidHandler?)

Save the ATT user choice and send it to our server.

Floating purpose allowed

appconsent.floatingPurposeAllowed(extraId: String) ->Bool

Check if floating purpose is allowed.

Note: You need to call checkForUpdate method before call this above method to stay up to date.

Display ATT if needed

appconsent.displayATTIfNeeded(_ completion: ((ACATTAuthorizationStatus)->Void)?)

For migrating existing users, you must call this method to display ATT popup without redisplaying CMP.

Note: ATT Popup will only display if user device supports ATT, user given his consent, purpose 1 is true and ATT not yet displaying.

WARNING After that, you need to call new saveATTFloatingPurpose(with value: Bool, _completion: ACResultVoidHandler?) method to send user choice on our server.

Delegate basic implementation

Presenting a notice also take a delegate parameter. It is an object conforming to the AppConsentDelegate protocol. Here are the main methods you'll need to implement.

appconsent.delegate = self
// called when the consent has been given
func appConsentDidFinish() {
print("consent did finish")
}
// called in case of error
func appConsentDidFail(_ error: Error) {
print("consent did fail: \(error.localizedDescription)")
}
func appConsentWillAppear() { ... }
func appConsentDidAppear() { ... }
func appConsentWillDisappear() { ... }
func appConsentDidDisappear() { ... }