Consent Management

mParticle’s Consent Management framework is designed to give brands the tools they need to manage their consent and privacy obligations under the European Union’s General Data Protection Regulation (GDPR).

Before instrumenting Consent State in your app, be sure to read our GDPR Consent Management Guide.

Consent state can be logged in the SDK using the Consent State API. Once a consent state is set, it cannot be modified. To change the consent state for a given purpose, you can either remove it, or replace it with a new complete consent state object.

MParticleUser *user = [MParticle sharedInstance].identity.currentUser;

// Create consent objects
MPGDPRConsent *locationCollectionConsent = [[MPGDPRConsent alloc] init];
gdprConsent.consented = YES;
gdprConsent.document = @"location_collection_agreement_v4";
gdprConsent.timestamp = date;
gdprConsent.location = @"17 Cherry Tree Lane";
gdprConsent.hardwareId = @"IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702";

MPGDPRConsent *parentalConsent = [[MPGDPRConsent alloc] init];
gdprConsent.consented = NO;
gdprConsent.document = @"parental_consent_agreement_v2";
gdprConsent.timestamp = date;
gdprConsent.location = @"17 Cherry Tree Lane";
gdprConsent.hardwareId = @"IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702";

// Add to consent state
MPConsentState *consentState = [[MPConsentState alloc] init];
[consentState addGDPRConsentState:locationCollectionConsent purpose:@"location_collection"];
[consentState addGDPRConsentState:parentalConsent purpose:@"parental"];
user.consentState = consentState;

// Remove consent state
MPConsentState *consentState2 = user.consentState;
[consentState2 removeGDPRConsentStateWithPurpose:@"parental"];
user.consentState = consentState2;
let user = MParticle.sharedInstance().identity.currentUser

// Create consent objects
let locationCollectionConsent = MPGDPRConsent.init()
locationCollectionConsent.consented = true
locationCollectionConsent.document = "location_collection_agreement_v4"
locationCollectionConsent.timestamp = Date.init()
locationCollectionConsent.location = "17 Cherry Tree Lane"
locationCollectionConsent.hardwareId = "IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702"

let parentalConsent = MPGDPRConsent.init()
parentalConsent.consented = false
parentalConsent.document = "parental_consent_agreement_v2"
parentalConsent.timestamp = Date.init()
parentalConsent.location = "17 Cherry Tree Lane"
parentalConsent.hardwareId = "IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702"

// Add to consent state
let consentState = MPConsentState.init()
consentState.addGDPRConsentState(locationCollectionConsent, purpose: "location_collection")
consentState.addGDPRConsentState(parentalConsent, purpose: "parental")

user?.setConsentState(consentState)

// Remove consent state
if let consentState2 = user?.consentState() {
    consentState2.removeGDPRConsentState(withPurpose: "parental")
    user?.setConsentState(consentState2)
}