Skip to main content

3. Build Conditional Logic (GDPR for Mobile)

The LiveRamp SDK shares the user consent status with vendors through the IAB Transparency and Consent Framework.

For vendors that support the framework (see the list here), the only thing you have to do is declare them in the list of vendors that your app uses (Configure Organization and Vendors (GDPR for Mobile)) and they will adapt their data processing to respect the user consent. This is because we assume that if a vendor follows the IAB specification and thus is TCF validated, their respective SDK is able to decode TC strings.

WIth LiveRamp SDK checking consent for vendors can be done by using API through checkConsent function. Consent can be checked for vendors, but also checking consent for purposes and special features is available and it is optional.

Consent can be checked by creating VendorData object and calling checkConsent function. More info about what is VendorData object and how checkConsent function should be called can be found on API reference iOS SDK and API reference Android SDK.

Caution

The function for checking consent should be called after SDK is initialized.

Code samples to check consent:

Java

        // LRPrivacyManagerCallback - implementation

        @Override
        public void eventTriggered(event: Event) {

            switch (event) {
            case USER_ACTION_COMPLETE:
                List<VendorData> vendorDataList = new ArrayList<>();
                // vendor 1, all claimed purposes & special features
                vendorDataList.add(new VendorData(1, new HashSet<Integer>(), new HashSet<Integer>()));
                // vendor 10002, purposes 1, 4 & special features 1, 2
                vendorDataList.add(new VendorData(10002, new HashSet<Integer>(1,4), new HashSet<Integer>(1,2)));

                List<VendorConsent> vendors = LRPrivacyManager.INSTANCE.checkConsent(vendorDataList);

                for(int i = 0; i<vendors.size(); i++){
                    System.out.println("vendor with id: " + vendors.get(i).getVendorId() + " has consent " + vendors.get(i).getHasConsent());
                    if(vendors.get(i).getHasConsent()){
                        doSomething()
                    }
                }
            }
        }

        void doSomething() {

        }

Kotlin

        // LRPrivacyManagerCallback - implementation

        override fun eventTriggered(event: Event) {

            when (event) {
                LREvent.USER_ACTION_COMPLETE -> {
                    val vendors = LRPrivacyManager.checkConsent(
                    mutableListOf(
                      // vendor 1, all claimed purposes & special features
                      VendorData(1, mutableSetOf(), mutableSetOf()),             
                      // vendor 10002, purposes 1, 4 & special features 1, 2
                      VendorData(10002, mutableSetOf(1, 4), mutableSetOf(1, 2))   
                    ))
                    vendors?.forEach{
                        println("vendor with id: " + it.vendorId + " has consent " + it.hasConsent)
                        if(vendor.hasConsent){
                            doSomething()
                        }
                    }
                }
            }
        }

        fun doSomething() {

        }

Swift

// checkConsents should be called after SDK is initialized...

import UIKit
import LRPrivacyManagerSDK

class ViewController: UIViewController {

    var manager: LRPrivacyManager?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        manager = LRPrivacyManager.shared
         
        manager?.initialize(sdkInitializedHandler: { (success, error) in
            let vendorConsents = self.manager?.checkConsent(for: [
                VendorData(vendorId: 1, purposesIds: [], specialFeaturesIds: []),
                VendorData(vendorId: 10002, purposesIds: [], specialFeaturesIds: [])
            ])
            
            // do something with the result of variable vendorConsents
        })
}

Objective-C

// checkConsents should be called after SDK is initialized...

#import "ViewController.h"
#import <LRPrivacyManagerSDK/LRPrivacyManagerSDK-Swift.h>

@interface ViewController ()

@property LRPrivacyManager *manager;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _manager = [LRPrivacyManager shared];
    __weak typeof (ViewController *) weakSelf = self;
    [_manager initializeWithSdkInitializedHandler:^(BOOL success, NSError *error) {
        
        // create vendorData objects that we want to check consent for
        VendorData *vendor1 = [[VendorData alloc] initWithVendorId: 1 purposesIds: nil  specialFeaturesIds: nil];
        VendorData *vendor10002 = [[VendorData alloc] initWithVendorId: 10002 purposesIds: @[@1, @4]  specialFeaturesIds: @[@1, @2]];

        // check consent for array of vendorData objects
        NSArray *vendorConsents = [[LRPrivacyManager shared] checkConsentFor: [NSArray arrayWithObjects:vendor1, vendor10002]];
        
        // do something with the result of variable vendorConsents
        
    }];
}

@end