Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

iOS CMP Integration Manual

Table of Contents
maxLevel2
minLevel2
include
outlineclear
indent
styledisc
exclude
typelist
printablefalse

1. Overview

SDK provides an optional Consent Collection feature or CMP. The SDK currently implements TCF v2. The TC string generated by the SDK is available to callers and can be found in the standard location as per TCF v2 specification.

...

2.1. Add SDK to your project with CocoaPods

...

Add CMP pod to your Podfile
Code Block
collapselanguagefalseruby
pod 'YieldloveConsent', '6.12.0'
Install
Code Block
languagebash
titleInstall
collapsefalse
$ pod install

Receive an APPLICATION_NAME for the app, where you would like to collect consent from users. Set the application name:

Set application name
Code Block
languageswift
titleSet application name
collapsefalse
YLConsent.instance.setAppName(appName: "APPLICATION_NAME")

2.2. Add SDK to your project with Carthage

  1. In your Cartfile add these dependencies (for more info about Cartfile see: https://github.com/Carthage/Carthage):

    Code Block

...

  1. binary "https://slabs-yieldlove-ad-integration.s3.eu-central-1.amazonaws.com/ios/carthage/YieldloveConsent/YieldloveConsent.json" == 6.

...

  1. 2.0
    binary "https://slabs-yieldlove-ad-integration.s3.eu-central-1.amazonaws.com/ios/carthage/YieldloveExternalConfiguration/YieldloveExternalConfiguration.json" == 0.

...

  1. 19.0
    github "https://github.com/SourcePointUSA/ios-cmp-app.git" == 7.0.1
    github "mxcl/PromiseKit" == 6.

...

  1. 21.

...

  1. 0
  2. Run carthage update --use-xcframeworks --platform ios

  3. Link downloaded and built .xcframeworks to the project

3. Simple Consent Message

...

To collect consent in this manner call YLConsent.instance.collect()

...

Collect consent in Swift
collapsetitle
Code Block
languagefalseswift
import YieldloveConsent

// ...

YLConsent.instance.setAppName(appName: "APPLICATION_NAME")
let viewController = UIViewController()
YLConsent.instance.collect(viewController: viewController, delegate: self)

// or with AuthId
let options = ConsentOptions()
options.authId = "uniqueAuthId"
YLConsent.instance.collect(viewController: self, delegate: self, options: options)

// or with language setting
let myOptions = ConsentOptions()
myOptions.language = .German
YLConsent.instance.collect(viewController: self, delegate: self, options: myOptions)
Code Block
languageobjective
theme-c
Collect consent in Objective-C
Code Block
collapselanguagefalseobjective
#import "YieldloveConsent-Swift.h"

// ...

[YLConsent.instance setAppNameWithAppName:@"appDfpTestCMP"];
ConsentOptions* options = [ConsentOptions new];
options.authId = @"uniqueAuthId";
[YLConsent.instance collectWithViewController: self delegate: self options: options];

...

To display Privacy Manager call YLConsent.instance.showPrivacyManager()

...

Display Privacy manager in Swift
collapsecode
Code Block
languagefalseswift
import YieldloveConsent

// ...

YLConsent.instance.setAppName(appName: "APPLICATION_NAME")
let viewController = UIViewController()
YLConsent.instance.showPrivacyManager(viewController: viewController, delegate: consentDelegate)

// or with language setting
let myOptions = ConsentOptions()
myOptions.language = .German
YLConsent.instance.showPrivacyManager(viewController: self, delegate: self, options: myOptions)
languageobjective
theme-c
title
Display Privacy manager in Objective-C
Code Block
collapselanguagefalseobjective
#import "YieldloveConsent-Swift.h"

// ...

[YLConsent.instance setAppNameWithAppName:@"appDfpTestCMP"];
ConsentOptions* options = [ConsentOptions new];
options.variant = @"variant";
[YLConsent.instance showPrivacyManagerWithViewController: self delegate: self options: options];

...

To show PUR layer, pass variant parameter into ConsentOptions object and call collect() or showPrivacyManager(). Ask publisher account management for the value of this property.

...

Pass variant to Privacy manager
Code Block
collapselanguagefalseswift
import YieldloveConsent

// ...

let options = ConsentOptions()
options.variant = "purLayer" // example, not real value
YLConsent.instance.showPrivacyManager(viewController: self, delegate: self, options: options)

...

After user makes their choices “dismiss” method is called by the SDK on the view controller that was passed into the API call:

...

Dismiss method signature
Code Block
collapselanguagefalseswift
func dismiss(animated flag: Bool, completion: (() -> Void)? = nil)

...

To do this, have a class implement ConsentDelegate protocol, specifically onSPUIFinished() method. SDK will call this method every time the user finishes making their choices, either using Simple Consent Message or Privacy Manager.

For example:

...

ConsentDelegate implementation in Swift
collapsecode
Code Block
languagefalseswift
import UIKit
import YieldloveAdIntegration

class AppConsentDelegate: ConsentDelegate {

    var viewRouter: ViewRouter

    init(viewRouter: ViewRouter) {
        self.viewRouter = viewRouter
    }

    func onSPUIFinished() {
        self.viewRouter.currentPage = "homeScreen"
    }

    func onError(error: ConsentError?) {
        print("Consent Error: \(error.debugDescription)")
        self.viewRouter.currentPage = "homeScreen"
    }
}
languageobjective
theme-c
title
ConsentDelegate implementation in Objective-C
Code Block
collapselanguagefalseobjective
#import "YieldloveConsent-Swift.h"
@import ConsentViewController;

@interface AppConsentDelegate () <ConsentDelegate>

@end

@implementation AppConsentDelegate

- (void)onConsentReadyWithConsents:(SPUserData *) {
    // at this point consent is given
}

@end

Then pass this class into the delegate property to the API calls. For example:

...

Collect consent with delegate
Code Block
collapselanguagefalseswift
let delegate = AppConsentDelegate(viewRouter: viewRouter)
YLConsent.instance.collect(viewController: viewController, delegate: delegate)

or

title
Code Block
languageswift
)

or

Show Privacy manager with delegate
Code Block
collapselanguagefalseswift
...
let delegate = AppConsentDelegate(viewRouter: viewRouter)
YLConsent.instance.showPrivacyManager(viewController: viewController, delegate: delegate)

Currently the SDK implements the following delegate methods (listeners):

Delegate methods
Code Block
title
languageswiftDelegate methods
collapsefalse
import ConsentViewController

// called when the consent view is ready to show
public func onSPUIReady()

// called when the consent view has been dismissed
public func onSPUIFinished()

// called when consent is available
public func onConsentReady(consents: SPUserData)

// called when something wrong happens in the consent view
public func onError(error: ConsentError?)

/// called when the user takes an action in the SP UI
public func onAction(action: SPAction)

Additionally, onAction(action: SPAction) can be called where action is one of:

Code Block
language
collapsefalse
case SaveAndExit = 1
case PMCancel = 2
case Custom = 9
case AcceptAll = 11
case ShowPrivacyManager = 12
case RejectAll = 13
case Dismiss = 15
case RequestATTAccess = 16
case IDFAAccepted = 17
case IDFADenied = 18
case Unknown = 0

...

To clear a previously stored consent this method is available:

...

Clear a previously stored consent
Code Block
collapselanguagefalseswift
...
let delegate = AppConsentDelegate(viewRouter: viewRouter)
clearConsentData(delegate: delegate)
...

...

It’s important to notice, this method is intended to be used for custom vendors and purposes only. For IAB vendors and purposes, it’s still required to get consent via the consent message or privacy manager.

false
Code Block
languagecollapse
import YieldloveConsent

...

let customConsentData = CustomConsentData(
    vendors: ["vendor1", "vendor2"],
    categories: ["cat1", "cat2"],
    legIntCategories: ["legacyCat1", "legacyCat2"]
)

YLConsent.instance.customConsentTo(
    customConsentData,
    completionHandler: { gdprUserConsent in
        // your code for the callback
    },
    delegate: delegate
)

...

If you want to use Authenticated Consent feature, pass authId parameter into ConsentOptions object and call collect().

Authenticated consent
Code Block
languageswift
titleAuthenticated consent
collapsefalse
let options = ConsentOptions()
options.authId = "uniqueAuthId"
YLConsent.instance.collect(viewController: self, delegate: self, options: options)

...

Updated SourcePoint ConsentViewController library to version 6.2.0, the official changelog can be found here

API breaking changes:

  • In the ConsentDelegate class the following functions have been updated:

    • onConsentReady(: GDPRUUID, : GDPRUserConsent) changed to onConsentReady(: SPUserData)

    • gdprConsentUIWillShow() changed to onSPUIReady()

    • consentUIDidDisappear() changed to onSPUIFinished()

New Feature:

  • Support for multi campaigns

  • Added callback method onAction to the delegate to forward certain supported action by SourcePoint

    • SPActionType.AcceptAll

    • SPActionType.RejectAll

    • SPActionType.ShowPrivacyManager

    • SPActionType.SaveAndExit

    • SPActionType.Dismiss

    • SPActionType.PMCancel

    • SPActionType.RequestATTAccess

    • SPActionType.IDFAAccepted

    • SPActionType.IDFADenied

    • SPActionType.Unknown

3.3.1 (11.10.2021)

Fixed Carthage deployment.

...

3.0.0

API breaking changes:

  • In collect(: UIViewController, : ConsentDelegate) and showPrivacyManager(: UIViewController, : ConsentDelegate) methods the second parameter delegate is now mandatory

  • Dropped manual configuration support for setting consent properties, only External Configuration is supported

New supported API Method:

  • Added a new method to clear the previously stored consent: clearConsentData(: ConsentDelegate)

Bugfixes:

  • The method customConsentTo() correctly invokes the completionHandler

2.1.2

  • Minimum iOS version is now iOS 10

2.1.0

  • Stability improvements and fixes to Consent and PM

2.0.0

API breaking changes:

  • onConsentReady now passes through the consent information received from SourcePoint, the signature of the method has changed