Customise the CMP

Customise vendors

Filter IAB Vendors

By default, all vendors will be displayed. Unlike some others CMP, we advice to set only vendors that you use in your application. To do this, just give the vendors id in the configuration object used to initilise the SDK:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        let vendorUsed = IndexSet([1,2,368,128,153]) // Use a IndexSet of vendors id

        let conf = CMPConfiguration(apiKey: apiKey, filter: vendorUsed)

        VectauryCMP.initWithConf(conf)
    }
}
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    NSString *lang = @"auto";
    NSIndexSet *vendorUsed = [[NSIndexSet alloc]initWithIndex:368];

    CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:NULL primaryColor:NULL subjectToGDPR:NULL filter:vendorUsed privacyPolicy:NULL];

    [VectauryCMP initWithConf:conf];
}
@end

Add Non-IAB Vendors

You can add Non IAB Vendor to the CMP. The vendor appear near the IAB Vendor (it's transparent for the user).

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        let conf = CMPConfiguration(apiKey: apiKey)

        let idForCustomVendor = 1 // id to get the authorisation status of vendor
        conf.addCustomVendor(CMPVendor(id: id, name: "Name of Vendor", purposeIds: [1,2,3], legIntPurposeIds: [4,5], featureIds: [1,2], policyUrl: "policy url"))

        VectauryCMP.initWithConf(conf)
    }
}
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    NSString *lang = @"auto";

    CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:NULL primaryColor:NULL subjectToGDPR:NULL filter:NULL privacyPolicy:NULL];

    NSIndexSet *purposeUsed = [[NSIndexSet alloc]initWithIndex:1];
    NSIndexSet *featureUsed = [[NSIndexSet alloc]initWithIndex:1];

    CMPVendor * vendor = [[CMPVendor alloc]initWithId:1 name:@"Name of Vendor" purposeIds:purposeUsed legIntPurposeIds:NULL featureIds:featureUsed policyUrl:@"policy url"];

    [conf addCustomVendor:vendor];

    [VectauryCMP initWithConf:conf];
}
@end

Info

consent string of Non-IAB are store separactly of IAB Consent String. You can use VectauryCMPConsentString to read it

import VectauryCMPConsentString

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        CSExtraVendorConsentString()?.isVendorAllowed(vendorId: 1)
    }
}
@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
NSString *lang = @"auto";

CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:NULL primaryColor:NULL subjectToGDPR:NULL filter:NULL privacyPolicy:NULL];

NSIndexSet *purposeUsed = [[NSIndexSet alloc]initWithIndex:1];
NSIndexSet *featureUsed = [[NSIndexSet alloc]initWithIndex:1];

CMPVendor * vendor = [[CMPVendor alloc]initWithId:1 name:@"Name of Vendor" purposeIds:purposeUsed legIntPurposeIds:NULL featureIds:featureUsed policyUrl:@"policy url"];

[conf addCustomVendor:vendor];

[VectauryCMP initWithConf:conf];
}
@end

Customise theme

To custum the color of the app, add it to configuration:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        let color : UIColor = .red

        let conf = CMPConfiguration(apiKey: apiKey, primaryColor: color)

        VectauryCMP.initWithConf(conf)
    }
}
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    NSString *lang = @"auto";
    UIColor *color = [[UIColor alloc]initWithRed:200/255.0 green:100/255.0 blue:50/255.0 alpha:1];

    CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:NULL primaryColor:color subjectToGDPR:NULL filter:NULL privacyPolicy:NULL];

    [VectauryCMP initWithConf:conf];
}
@end

Customise privacy notice

The privacy notice is the first screen displayed to the user when asking consent.

You can add your own logo at the top of the privacy notice. For this, provide the drawable resource id in the configuration object used to initilise the SDK:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        let logo : UIImage? = UIImage(named: "logo.jpg") // need to be compatible with UIImageJPEGRepresentation

        let conf = CMPConfiguration(apiKey: apiKey, logo: logo)

        VectauryCMP.initWithConf(conf)
    }
}
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    NSString *lang = @"auto";
    UIImage *logo = [UIImage imageNamed:@"logo.jpg"];

    CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:logo primaryColor:NULL subjectToGDPR:NULL filter:NULL privacyPolicy:NULL];

    [VectauryCMP initWithConf:conf];
}
@end

Add your privacy policy

You need to provide your privacy policy to the user. For this, provide your privacy policy url in the configuration object used to initilise the SDK:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        let privacyPolicy: String = "https://www.vectaury.io/en/personal-data"

        let conf = CMPConfiguration(apiKey: apiKey, privacyPolicy: privacyPolicy)

        VectauryCMP.initWithConf(conf)
    }
}
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    NSString *lang = @"auto";
    NSString *privacyPolicy = @"https://www.vectaury.io/en/personal-data";

    CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:NULL primaryColor:NULL subjectToGDPR:NULL filter:NULL privacyPolicy:privacyPolicy];

    [VectauryCMP initWithConf:conf];
}
@end

Force subject to GDPR

By default, the CMP is displayed only when the user is in EU (based on IP). We advice you to give access to the CMP UI even if the user is not in EU, for this, force the user to be subject to GDPR in the configuration object used to initilise the SDK:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        let subjectToGDPR: Bool = true

        let conf = CMPConfiguration(apiKey: apiKey, subjectToGDPR: subjectToGDPR)

        VectauryCMP.initWithConf(conf)
    }
}
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *apiKey = @"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    NSString *lang = @"auto";
    NSString *subjectToGDPR = @"1";

    CMPConfiguration *conf = [[CMPConfiguration alloc]initWithObjcApiKey:apiKey language:lang logo:NULL primaryColor:NULL subjectToGDPR:subjectToGDPR filter:NULL privacyPolicy:NULL];

    [VectauryCMP initWithConf:conf];
}
@end

You can get the encoded consent string with the following code:

let iabCMPConsentString = "IABConsent_ConsentString"
UserDefaults.standard.string(forKey: iabCMPConsentString)
NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"IABConsent_ConsentString"];

You can decode the consent string if needed:

import VectauryCMPConsentString

...


let consentStringDecoded = CSVendorConsentString(whithUserDefault: UserDefaults.standard)
let publisherConsentStringDecoded = CSPublisherConsentString(whithUserDefault: UserDefaults.standard)
let customVendorConsentStringDecoded = CSExtraVendorConsentString(whithUserDefault: UserDefaults.standard)

guard consentStringDecoded != nil && publisherConsentStringDecoded != nil && customVendorConsentStringDecoded != nil else {
    print("Decode failed")
    return
}

print(consentStringDecoded!.isVendorAllowed(vendorId: 368))
print(publisherConsentStringDecoded!.isCustomPurposeAllowed(purposeId: 1))
print(customVendorConsentStringDecoded!.isVendorAllowed(vendorId: 15))
#import <VectauryCMPConsentString/VectauryCMPConsentString.h>

...


CSPublisherConsentString *publisher = [[CSPublisherConsentString alloc]initWithWhithUserDefault:[NSUserDefaults standardUserDefaults]];
CSVendorConsentString *vendor = [[CSVendorConsentString alloc]initWithWhithUserDefault:[NSUserDefaults standardUserDefaults]];
CSExtraVendorConsentString *extra = [[CSExtraVendorConsentString alloc]initWithWhithUserDefault:[NSUserDefaults standardUserDefaults]];

NSLog(@"%d",[publisher isStandardPurposeAllowedWithPurposeId:1]);
NSLog(@"%d",[vendor isVendorAllowedWithVendorId:368]);
NSLog(@"%d",[extra isVendorAllowedWithVendorId:15]);