Consent Handling
Consent Status
Section titled “Consent Status”You can check the current consent status by calling:
val result = spConsentEngine.getConsentStatus("YOUR_APPLICATION_ID")val status: SPConsentStatus = result.data
when (status) { SPConsentStatus.PENDING -> { // Show consent banner } SPConsentStatus.COLLECTED -> { // Proceed normally } SPConsentStatus.RECOLLECTION_REQUIRED -> { // Trigger re-consent flow }}SPConsentStatus values
Section titled “SPConsentStatus values”| Enum constant | Meaning |
|---|---|
PENDING | Consent needs to be collected. |
COLLECTED | Consent has already been obtained. |
RECOLLECTION_REQUIRED | Consent needs to be re-collected. |
Consent Recollection Reason
Section titled “Consent Recollection Reason”When the SDK determines that consent needs to be recollected (for example, a consent update/re-consent flow), you can fetch the reason by calling:
val result = spConsentEngine.getConsentRecollectionReason("YOUR_APPLICATION_ID")val reason: SPConsentRecollectionReason? = result.datareason?.let { when (it) { SPConsentRecollectionReason.EXPIRED -> { /* handle */ } SPConsentRecollectionReason.STRUCTURE_CHANGED -> { /* handle */ } }}If no recollection reason is available, reason will be null.
SPConsentRecollectionReason values
Section titled “SPConsentRecollectionReason values”| Enum constant | Meaning |
|---|---|
EXPIRED | Consent has expired and needs to be re-collected. |
STRUCTURE_CHANGED | Packages and services hash mismatch. |
Enum usage guidance
Section titled “Enum usage guidance”SDK enums are the authoritative representation for consent status and recollection reasons. The SDK guarantees the enum contract (what cases are possible), but does not guarantee that the underlying wire/raw string values are stable over time (those are serialization details and may change).
Strongly prefer enums e.g. SPConsentStatus or SPConsentRecollectionReason in app logic.
- Use enums in the control flow:
when (status) { ... }orwhen (reason) { ... }. - Avoid branching on raw keys such as
"expired","Collected", or"RecollectionRequired". - If you need your own string identifiers, define app-specific keys and create a custom mapping, for example:
val myReasonKey: String? = when (reason) { SPConsentRecollectionReason.EXPIRED -> "MY_EXPIRED" SPConsentRecollectionReason.STRUCTURE_CHANGED -> "MY_STRUCTURE_CHANGED" null -> null}This guidance applies to all enum fields returned from SDK APIs.
Check If a Package Is Enabled
Section titled “Check If a Package Is Enabled”To check whether a specific package is enabled based on user consent, you can call:
val result = spConsentEngine.getPackage(packageId, "YOUR_APPLICATION_ID")val pkg = result?.dataif (pkg != null && pkg.isEnabled) { // Enable features}This returns an SPDataMessage containing the SPMobilePackage. You should check isEnabled to determine whether the user has consented.
Collecting Consent
Section titled “Collecting Consent”To launch the consent collection banner, use the following method:
spConsentEngine.showConsentBanner(activity)This banner informs users about data collection and provides options to accept or deny consent. You can also display the secondary consent banner using:
spConsentEngine.showSecondaryBanner(activity)
Customization Options
Section titled “Customization Options”The consent banner supports customization options and displays a “Customize” button that allows users to adjust their consent preferences. When they click the customization button, they will be directed to the Preference Center, where they can:
- View a list of frameworks and their services.
- Enable or disable consent for specific services.
To display the Preference Center directly, simply start the Preference Center activity:
spConsentEngine.showPreferenceCenter(activity, "YOUR_APPLICATION_ID")Declaring SPPreferenceCenter activity in the Manifest
Section titled “Declaring SPPreferenceCenter activity in the Manifest”To properly use the Preference Center Activity, you need to declare it in your app’s AndroidManifest.xml file. Add the following line inside the <application> tag:
<activity android:name="ai.secureprivacy.mobileconsent.ui.preference_center.SPPreferenceCenter" android:theme="@style/Theme.SecurePrivacyMobile"/>This registers the SDK’s Preference Center activity, allowing it to be launched correctly.
Essential Services
Section titled “Essential Services”You can mark certain services as essential. These services will not be optional for the user to deny, ensuring compliance with the app’s required functionalities.
Privacy and Cookie Policy
Section titled “Privacy and Cookie Policy”The Preferences screen also includes tabs showcasing content related to the app’s privacy and cookie policies. This ensures users have access to essential information regarding their data handling.
Data Requests
Section titled “Data Requests”Users can submit a request for their data by filling out a form in the Request Data section. This feature helps manage user data requests in compliance with privacy regulations.