Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

Mobile App Consent Management

Beta Feature

Mobile App Consent Management is in beta for select customers and prospects. Please contact your Account Manager or support@datagrail.io for more information.

DataGrail provides native SDKs for iOS and Android that enable seamless consent management in your mobile applications. These SDKs offer fully native UI components, offline support, and automatic synchronization with the DataGrail backend.

The DataGrail Consent mobile SDKs allow your app to:

  • Display native consent banners that match your app's look and feel
  • Collect and store user preferences with automatic persistence
  • Sync consent choices with the DataGrail backend
  • Check consent status before initializing tracking SDKs
  • Work offline with automatic retry when connectivity returns
Choose Your Platform
  • iOS SDK Guide — Swift Package Manager, CocoaPods, native UIKit implementation
  • Android SDK Guide — Gradle integration, Kotlin-first, Material Design components

Getting Started

Setting up the mobile SDK requires a published configuration from the DataGrail console and platform-specific installation steps.

Create Your Configuration

Before integrating the SDK, set up your consent configuration in the DataGrail console:

  1. Navigate to ConsentConfigurations
  2. Create or select a configuration for mobile
  3. Define your consent categories (e.g., Analytics, Marketing, Functional)
  4. Customize banner text and appearance
  5. Publish your configuration

After publishing, you'll receive a configuration URL in this format:

https://api.consent.datagrail.io/config/YOUR_CONFIG_ID.json

Install the SDK

Choose your platform and follow the installation guide:

PlatformMinimum VersionInstallation Methods
iOSiOS 13.0+Swift Package Manager, CocoaPods
AndroidAPI 21+Gradle

Initialize and Display

Both SDKs follow a similar pattern:

  1. Initialize
  2. Check if consent needed
  3. Show banner
  4. Handle preferences

See the platform-specific guides for complete code examples.

Configuration

Your configuration defines how the SDK behaves, what categories are available, and how the banner appears to users.

Config.json Structure

Your published configuration controls the SDK behavior:

{
"showBanner": true,
"categories": [
{
"key": "category_essential",
"name": "Essential Cookies",
"description": "Required for the app to function",
"required": true,
"defaultEnabled": true
},
{
"key": "category_analytics",
"name": "Analytics",
"description": "Help us understand how you use the app",
"required": false,
"defaultEnabled": false
},
{
"key": "category_marketing",
"name": "Marketing",
"description": "Personalized ads and content",
"required": false,
"defaultEnabled": false
}
],
"banner": {
"title": "Privacy Preferences",
"description": "We use cookies and similar technologies...",
"acceptAllText": "Accept All",
"rejectAllText": "Reject All",
"savePreferencesText": "Save Preferences"
}
}

Category Keys

Use consistent category keys across platforms to ensure preferences sync correctly:

KeyPurposeTypical SDKs
category_essentialApp functionality
category_analyticsUsage analyticsFirebase, Mixpanel, Amplitude
category_marketingAdvertisingFacebook, Google Ads, AppsFlyer
category_functionalEnhanced featuresIntercom, Zendesk

API Overview

Both SDKs provide equivalent APIs with platform-appropriate naming conventions:

OperationiOS (Swift)Android (Kotlin)
InitializeDataGrailConsent.shared.initialize(configURL:)DataGrailConsent.getInstance().initialize(context, url)
Check consent neededneedsConsent()needsConsent()
Show bannershowBanner(from:style:)showBanner(activity, style)
Get preferencesgetPreferences()getPreferences()
Check categoryisCategoryEnabled(_:)isCategoryEnabled(key)
Accept allacceptAll()acceptAll()
Reject allrejectAll()rejectAll()
Listen for changesonConsentChanged(_:)onConsentChanged { }
Resetreset()reset()

Integration Best Practices

Follow these recommendations to ensure your consent implementation works reliably and provides the best user experience.

Initialize Early

Initialize the SDK as early as possible in your app's lifecycle:

  • iOS: In application(_:didFinishLaunchingWithOptions:) or your SwiftUI App init
  • Android: In your Application.onCreate()

Gate Tracking SDKs

Always check consent before initializing tracking:

// Pseudo-code pattern
if (consent.isCategoryEnabled("category_analytics")) {
initializeAnalytics()
}

if (consent.isCategoryEnabled("category_marketing")) {
initializeAds()
}

Register for consent change notifications to update tracking state:

consent.onConsentChanged { preferences ->
updateTrackingConfiguration(preferences)
}

Provide Settings Access

Give users a way to update their preferences from your app's settings screen. Both SDKs allow showing the banner at any time, regardless of needsConsent() status.

Offline Behavior

Both SDKs handle network failures gracefully:

  1. Preferences save locally first — Users never wait for network calls
  2. Backend sync happens asynchronously — Failed syncs are queued
  3. Automatic retry with exponential backoff — Up to 5 attempts
  4. Manual retry availableretryPendingRequests() method

Accessibility

The SDKs provide full accessibility support:

  • iOS: VoiceOver support with proper trait annotations
  • Android: TalkBack support with content descriptions
  • Both: Proper focus management and state announcements

Legacy WebView Implementation

Native SDKs Recommended

The native SDKs described above are the recommended approach for new integrations. The WebView approach below is provided for reference but offers a less native user experience.

You can also implement consent using a web view that loads the DataGrail Consent banner. This approach embeds the web-based banner into your mobile app.

Legacy WebView Implementation

Configure Embedded Container

  1. Create an Embedded Container
  2. Customize and configure your banner layouts by policy
  3. Publish your changes to the container
  4. Retrieve the JavaScript code for embedding

Mobile Layer

For each layout, you can create a third unlinked layer called Mobile View that will be triggered by a mobile device.

Android WebView Reference Implementation

Download Android Reference Code

iOS WebView Reference Implementation

Download iOS Reference Code

 

Need help?
If you have any questions, please reach out to your dedicated Account Manager or contact us at support@datagrail.io.

Disclaimer: The information contained in this message does not constitute as legal advice. We would advise seeking professional counsel before acting on or interpreting any material.