UMP(User Messaging Platform)SDKは、GDPR(一般データ保護規則)およびCCPA(カリフォルニア消費者プライバシー法)準拠のために、パーソナライズド広告に対するユーザーの同意を管理します。
UMP連携にはadrop-ads-backfillモジュールが必要です。はじめにのインストールガイドを先に完了してください。
基本的な使い方
Adrop初期化後にConsent Managerを使用してユーザーの同意を要求します。
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';
// Adrop.initialize()の後に呼び出し
Adrop.consentManager.requestConsentInfoUpdate((result) {
if (result.error != null) {
debugPrint('Consent error: ${result.error}');
}
});
同意ステータス
Consent Managerは次のステータスのいずれかを返します:
| ステータス | 説明 |
|---|
unknown | 同意ステータスがまだ決定されていない |
required | 同意が必要(ポップアップが表示される) |
notRequired | 同意は不要(非GDPR地域) |
obtained | すでに同意を取得済み |
デバッグ設定(テストモード)
開発中にGDPR/CCPA同意フローをテストしてください:
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';
// 同意リクエスト前にデバッグ地域を設定
// デバイスIDは自動的に適用される
await Adrop.consentManager.setDebugSettings(AdropConsentDebugGeography.eea); // GDPRテスト
// テスト用に同意をリセット
await Adrop.consentManager.reset();
デバッグ地域
| 地域 | 説明 |
|---|
disabled | 実際のデバイス位置を使用 |
eea | GDPRテスト(欧州経済領域) |
regulatedUSState | CCPAテスト(カリフォルニアなど) |
other | 非規制地域テスト |
デバッグ設定は開発中のみ使用してください。本番リリース前に削除または無効化してください。
完全な例
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 {
// まずAdropを初期化
await Adrop.initialize(false);
// デバッグモードでデバッグ設定
const bool isDebug = bool.fromEnvironment('dart.vm.product') == false;
if (isDebug) {
await Adrop.consentManager.setDebugSettings(AdropConsentDebugGeography.eea);
}
// 同意情報更新をリクエスト
Adrop.consentManager.requestConsentInfoUpdate((result) {
if (result.error != null) {
debugPrint('同意エラー: ${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('同意ステータス: $_consentStatus'),
const SizedBox(height: 16),
ElevatedButton(
onPressed: _resetConsent,
child: const Text('同意をリセット'),
),
],
),
),
);
}
}
ベストプラクティス
早期リクエスト
SDK初期化直後、アプリライフサイクルの早い段階で同意を要求してください。
エラー処理
同意エラーを適切に処理し、フォールバック動作を提供してください。
全シナリオテスト
リリース前にデバッグ設定を使用してすべての同意シナリオをテストしてください。
ユーザー選択の尊重
同意を得たり拒否された後は、ユーザーの選択を尊重し、繰り返し要求しないでください。
関連ドキュメント