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.getInstance().Identity().getCurrentUser();
        
// Create GDPRConsent
GDPRConsent locationCollectionConsent = GDPRConsent.builder(true)
        .document("location_collection_agreement_v4")
        .location("17 Cherry Tree Lane")
        .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702")
        .build();

GDPRConsent parentalConsent = GDPRConsent.builder(false)
        .document("parental_consent_agreement_v2")
        .location("17 Cherry Tree Lane")
        .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702")
        .build();

// Add to your consent state
ConsentState state = ConsentState.builder()
        .addGDPRConsentState("location_collection", locationCollectionConsent)
        .addGDPRConsentState("parental", parentalConsent)
        .build();

user.setConsentState(state);

// Remove Consent State
ConsentState updatedState = ConsentState.withConsentState(state)
        .removeGDPRConsentState("parental")
        .build();

user.setConsentState(updatedState);
var user = MParticle.getInstance().Identity().currentUser;

// Create GDPRConsent
var locationCollectionConsent = GDPRConsent.builder(true)
        .document("location_collection_agreement_v4")
        .location("17 Cherry Tree Lane")
        .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702")
        .build()

var parentalConsent = GDPRConsent.builder(false)
        .document("parental_consent_agreement_v2")
        .location("17 Cherry Tree Lane")
        .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702")
        .build()

// Add to your consent state
var state = ConsentState.builder()
        .addGDPRConsentState("location_collection", locationCollectionConsent)
        .addGDPRConsentState("parental", parentalConsent)
        .build()

user?.setConsentState(state);

// Remove Consent State
var updatedState = ConsentState.withConsentState (state)
        .removeGDPRConsentState("parental")
        .build();

user?.setConsentState(updatedState);