Handling Active Consent
The SDK provides explicit control over user consent, allowing it to operate in either consented or non-consented mode.
Configuration inputs
Active consent behavior is controlled by two parameters:
-
activeConsentIntegration
Enables or disables active consent logic in the SDK. -
activeConsentAccepted
Represents the user’s consent state:true→ consent granted (consented mode)false→ consent denied (non-consented mode)null→ no explicit consent state provided
Important:
The SDK does not persist consent across app launches. The application must provide the current activeConsentAccepted value on every SDK initialization.
Runtime updates
Consent can be updated during an active session using:
setActiveConsentAccepted(value)
- Applies immediately within the current session
- Only effective when
activeConsentIntegration = true
Behavior summary
Active consent enabled (activeConsentIntegration = true)
activeConsentIntegration = true)- SDK operates based on the provided
activeConsentAcceptedvalue. - Consent can be updated at runtime via
setActiveConsentAccepted(...). - When
activeConsentAccepted = false:- The SDK operates in non-consented mode.
- Consent-based tracking is disabled.
- Non-personalized campaigns can still be delivered.
Active consent disabled (activeConsentIntegration = false)
activeConsentIntegration = false)- Active consent logic is ignored.
- The SDK always operates in consented mode.
- Full tracking is enabled regardless of
activeConsentAccepted. - Any provided consent value is ignored.
Sample flows
User has not yet given consent
Initialize the SDK with activeConsentAccepted = false. The SDK does not perform consented tracking, but the user can still be served with non-personalized campaigns.
User grants consent during session
Call setActiveConsentAccepted(true) to switch the SDK to consented mode immediately.
User withdraws consent during session
Call setActiveConsentAccepted(false) to switch the SDK to non-consented mode immediately.
Active consent is disabled
If activeConsentIntegration = false, the SDK ignores all consent values and always behaves as if consent was given.
Kotlin code sample
private suspend fun initWithActiveConsentAccepted(
applicationContext: android.content.Context
) {
DYSdk.getInstance().initialize(
"your_api_key",
DataCenter.US,
context = applicationContext,
channel = Channel.APP,
isImplicitImpressionMode = true,
isImplicitPageview = true,
activeConsentIntegration = true,
activeConsentAccepted = true
)
// User grants consent
DYSdk.getInstance().setActiveConsentAccepted(true)
// User withdraws consent
DYSdk.getInstance().setActiveConsentAccepted(false)
} Notes:
channel = Channel.APPis optional ifChannel.APPis already the default- Set
activeConsentAcceptedduring initialization based on the current app consent state - Call
setActiveConsentAccepted(...)whenever the user updates their consent choice
Updated about 3 hours ago