Skip to main content

Overview

The User Messaging Platform (UMP) SDK helps you manage user consent for personalized advertising in compliance with GDPR (General Data Protection Regulation) and CCPA (California Consumer Privacy Act).
UMP integration requires the adrop-ads-backfill module. Make sure you have completed the Getting Started installation guide first.

Basic Usage

Use the Consent Manager to request user consent after initializing Adrop.
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';

// Call after Adrop.initialize()
Adrop.consentManager.requestConsentInfoUpdate((result) {
  if (result.error != null) {
    debugPrint('Consent error: ${result.error}');
  }
});

The consent manager returns one of the following statuses:
StatusDescription
unknownConsent status not yet determined
requiredConsent required (popup will be shown)
notRequiredConsent not required (non-GDPR region)
obtainedConsent already obtained

Debug Settings (Test Mode)

Test GDPR/CCPA consent flows during development:
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';

// Set debug geography before requesting consent
// Device ID is automatically applied
await Adrop.consentManager.setDebugSettings(AdropConsentDebugGeography.eea);  // Test GDPR

// Reset consent for testing
await Adrop.consentManager.reset();

Debug Geographies

GeographyDescription
disabledUse actual device location
eeaTest GDPR (European Economic Area)
regulatedUSStateTest CCPA (California, etc.)
otherTest non-regulated regions
Debug settings should only be used during development. Remove or disable them before releasing to production.

Complete Example

import 'package:flutter/material.dart';
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';

class ConsentExample extends StatefulWidget {
  const ConsentExample({super.key});

  @override
  State<ConsentExample> createState() => _ConsentExampleState();
}

class _ConsentExampleState extends State<ConsentExample> {
  String _consentStatus = 'unknown';

  @override
  void initState() {
    super.initState();
    _initializeConsent();
  }

  Future<void> _initializeConsent() async {
    // Initialize Adrop first
    await Adrop.initialize(false);

    // Set debug settings in debug mode
    const bool isDebug = bool.fromEnvironment('dart.vm.product') == false;
    if (isDebug) {
      await Adrop.consentManager.setDebugSettings(AdropConsentDebugGeography.eea);
    }

    // Request consent info update
    Adrop.consentManager.requestConsentInfoUpdate((result) {
      if (result.error != null) {
        debugPrint('Consent error: ${result.error}');
      } else {
        setState(() {
          _consentStatus = result.status?.toString() ?? 'unknown';
        });
      }
    });
  }

  Future<void> _resetConsent() async {
    await Adrop.consentManager.reset();
    await _initializeConsent();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Consent Status: $_consentStatus'),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: _resetConsent,
              child: const Text('Reset Consent'),
            ),
          ],
        ),
      ),
    );
  }
}

Best Practices

Request Early

Request consent as early as possible in your app lifecycle, ideally right after SDK initialization.

Handle Errors

Always handle consent errors gracefully and provide fallback behavior.

Test All Scenarios

Use debug settings to test all consent scenarios (required, not required, obtained) before release.

Respect User Choice

Once consent is obtained or declined, respect the user’s choice and don’t repeatedly ask.