❗The CCPA SDK is now part of the Unified SDK. This repo is now deprecated.
We strongly recommend the use of CocoaPods in order to install our SDK.
In your Podfile
add the following line to your app target:
pod 'CCPAConsentViewController', '1.5.0'
We also support Carthage. It requires a couple more steps to install so we dedicated a whole wiki page for it. Let us know if we missed any step.
We also support Swift Package Manager. It is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but SourcePoint does support its use on iOS platform.
To add our SDK package as dependency to your Xcode project, In Xcode select File > Swift Packages > Add Package Dependency and enter our SDK repository URL.
https://github.com/SourcePointUSA/CCPA_iOS_SDK.git
We also support Manual integration of SDK. It requires a couple more steps to install so we dedicated a whole wiki page for it. Let us know if we missed any step.
It's pretty simple, here are 5 easy steps for you:
- implement the
ConsentDelegate
protocol - instantiate the
CCPAConsentViewController
with your Account ID, property id, property name, privacy manager id, campaign environment and the consent delegate - call
.loadMessage()
when your app starts or.loadPrivacyManager()
when you wish to show the PrivacyManager. - present the controller when the message/PM is ready to be displayed
- profit!
import CCPAConsentViewController
class ViewController: UIViewController {
let logger = Logger()
lazy var consentViewController: CCPAConsentViewController = { return CCPAConsentViewController(
accountId: 22,
propertyId: 6099,
propertyName: try! PropertyName("ccpa.mobile.demo"),
PMId: "5df9105bcf42027ce707bb43",
campaignEnv: .Public,
consentDelegate: self
)}()
@IBAction func onPrivacySettingsTap(_ sender: Any) {
consentViewController.loadPrivacyManager()
}
override func viewDidLoad() {
super.viewDidLoad()
consentViewController.loadMessage()
}
}
extension ViewController: ConsentDelegate {
func ccpaConsentUIWillShow() {
present(consentViewController, animated: true, completion: nil)
}
func consentUIDidDisappear() {
dismiss(animated: true, completion: nil)
}
func onConsentReady(consentUUID: ConsentUUID, userConsent: UserConsent) {
print("consentUUID: \(consentUUID)")
print("userConsents: \(userConsent)")
print("CCPA applies:", UserDefaults.standard.bool(forKey: CCPAConsentViewController.CCPA_APPLIES_KEY))
print("US Privacy String:", UserDefaults.standard.string(forKey: CCPAConsentViewController.IAB_PRIVACY_STRING_KEY)!)
}
func onError(ccpaError: CCPAConsentViewControllerError?) {
logger.log("Error: %{public}@", [ccpaError?.description ?? "Something Went Wrong"])
}
}
#import "ViewController.h"
@import CCPAConsentViewController;
@interface ViewController ()<ConsentDelegate> {
CCPAConsentViewController *ccpa;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
PropertyName *propertyName = [[PropertyName alloc] init:@"ccpa.mobile.demo" error:NULL];
ccpa = [[CCPAConsentViewController alloc]
initWithAccountId:22
propertyId:6099
propertyName:propertyName
PMId:@"5df9105bcf42027ce707bb43"
campaignEnv:CampaignEnvPublic
consentDelegate:self];
[ccpa loadMessage];
}
- (void)consentUIWillShow {
[self presentViewController:ccpa animated:true completion:NULL];
}
- (void)consentUIDidDisappear {
[self dismissViewControllerAnimated:true completion:nil];
}
- (void)onConsentReadyWithConsentUUID:(NSString *)consentUUID userConsent:(UserConsent *)userConsent {
NSLog(@"ConsentUUID: %@", consentUUID);
NSLog(@"US Privacy String: %@", userConsent.uspstring);
NSLog(@"Consent status: %ld", (long)userConsent.status);
for (id vendorId in userConsent.rejectedVendors) {
NSLog(@"Rejected to Vendor(id: %@)", vendorId);
}
for (id purposeId in userConsent.rejectedCategories) {
NSLog(@"Rejected to Purpose(id: %@)", purposeId);
}
}
- (void)onErrorWithCcpaError:(CCPAConsentViewControllerError *)ccpaError {
NSLog(@"Something went wrong: %@", ccpaError);
}
@end
You need to give us a authId
, that can be anything, user name, email, uuid, as long as you can uniquely identifies an user in your user base.
We'll check our database for a consent profile associated with that authId
. If we find one, we'll bring it to the user's device and not show a consent message again (technically this will depend on the scenario setup in our dashboard). If we haven't found any consent profile for that authId
we'll create one and associate with the current user.
The workflow to use authenticated consent is exactly the same as the one above but instead of calling:
consentViewController.loadMessage()
you should use:
consentViewController.loadMessage(forAuthId: String?)
When the user takes an action within the consent UI, it's possible to attach an arbitrary payload to the action data an have it sent to our endpoints. For more information on how to do that check our wiki: Sending arbitrary data when the user takes an action