Consent Management
Engagement Mobile SDK offers a managed solution for allowing and restricting collection
of event data. Your mobile application is responsible for presenting the device owner with the
choice to opt in or opt out of data collection and for setting the Salesforce CDP Module consent
property accordingly.
Consent States
This table describes the Salesforce CDP Module consent states.
| iOS Values | Android Values | Description |
|---|---|---|
| Consent.optIn | Consent.OPT_IN | In this state, events are transmitted to the configured Salesforce CDP endpoint for collection. If queued events are present, the Salesforce CDP Module transmits them immediately to Salesforce CDP. |
| Consent.optOut | Consent.OPT_OUT | In this state, events created by the mobile application are ignored by the SDK. The events are never queued or transmitted off the device. If queued events are present, the Salesforce CDP Module deletes them from memory. |
| Consent.pending | Consent.PENDING | The default consent value for a newly initialized Salesforce CDP Module is pending. In this state, events are collected locally until an opt-in or opt-out state is set. |
Granting or Revoking Consent
The Salesforce CDP Module can’t transmit events from a mobile device to Salesforce CDP until the mobile application has collected customer consent for data collection.
If no prior consent has been set, then the initial state is pending. In this state, events are queued locally until consent is granted or revoked. If consent is granted, the queued events are transmitted to Salesforce CDP. If revoked, they’re deleted from the queue.
iOS1import Cdp
2
3...
4
5// when a user consents to data collection
6CdpModule.shared.setConsent(consent: Consent.optIn)
7
8// when a user does not consent to data collection
9CdpModule.shared.setContent(consent: Consent.optOut)1import com.salesforce.marketingcloud.cdp.CdpSdk
2import com.salesforce.marketingcloud.cdp.consent.Consent.OPT_IN
3import com.salesforce.marketingcloud.cdp.consent.Consent.OPT_OUT
4
5...
6
7// when a user consents to data collection
8CdpSdk.requestSdk { sdk -> sdk.consent = OPT_IN }
9
10// when a user does not consent to data collection
11CdpSdk.requestSdk { sdk -> sdk.consent = OPT_OUT }Reading Consent State
Access the current state of consent in the Salesforce CDP Module:
iOS1let consent = CdpModule.shared.getConsent()1CdpSdk.requestSdk { sdk ->
2 let consent = sdk.consent
3}