The RudderStack iOS SDK lets you specify the user’s consent during initialization.
The RudderStack iOS SDK supports OneTrust consent management from version 1.9.0.
This guide lists the steps to develop a consent interceptor for the iOS SDK and use the interceptor to initialize the SDK once the user gives their consent.
Overview
The consent management is designed to be a filter for the event destinations and the natively added factories. Since the SDK initializes the native integration factories during the startup, you must capture the user’s consent to the cookie categories by then.
You can add only one consent filter to the iOS SDK.
For filtering, RudderStack uses the getConsentStatus(forCategory categoryId: String) method from the OneTrust SDK.
Installing OneTrust consent
This setup assumes the iOS SDK and the OneTrust SDK are already added to your application.
Install RudderOneTrustConsentFilter by adding the following line to your Podfile:
pod'RudderOneTrustConsentFilter','~> 1.0.0'
Import the iOS SDK:
@importRudderOneTrustConsentFilter;
importRudderOneTrustConsentFilter
Finally, add the imports to your AppDelegate file under the didFinishLaunchingWithOptions method, as shown:
#import "CustomConsentFilter.h"
@implementationCustomConsentFilter-(NSDictionary<NSString*,NSNumber*>*__nullable)filterConsentedDestinations:(NSArray<RSServerDestination*>*)destinations{NSDictionary<NSString*,NSNumber*>*filteredConsentedDestinations;// Do someting
returnfilteredConsentedDestinations;}@end
Create a CustomConsentFilter file by extending RSConsentFilter.
@objcopenclassOneTrustInterceptor:NSObject,RSConsentFilter{@objcpublicoverrideinit(){super.init()}publicfuncfilterConsentedDestinations(_destinations:[RSServerDestination])->[String:NSNumber]?{letfilteredConsentedDestinations:[String:NSNumber]// Your codereturnfilteredConsentedDestinations}}
Registering consent filter with iOS SDK
You can register CustomConsentFilter with the iOS SDK during its initialization, as shown:
In the destination’s connection settings, enter the OneTrust category ID in the Category ID field:
When sending events via the cloud mode, make sure you enter the category ID corresponding to the OneTrust cookie category. Specifying the category name will not work.
You can find the category IDs in your OneTrust dashboard under Preference & Consent Management > Cookie Compliance > Categorizations > Categories.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.