UMP(User Messaging Platform)SDKは、GDPR(一般データ保護規則)およびCCPA(カリフォルニア消費者プライバシー法)準拠のために、パーソナライズド広告に対するユーザーの同意を管理します。
UMP連携にはadrop-ads-backfillネイティブモジュールが必要です。はじめにのインストールガイドを先に完了してください。
基本的な使い方
Adrop初期化後にAdropConsentモジュールを使用してユーザーの同意を要求します。
import { AdropConsent } from 'adrop-ads-react-native'
// Adrop.initialize()の後に呼び出し
const requestConsent = async () => {
const result = await AdropConsent.requestConsentInfoUpdate()
if (result.error) {
console.error('Consent error:', result.error)
}
}
同意ステータス
Consent Managerは次のステータスのいずれかを返します:
| ステータス | 説明 |
|---|
UNKNOWN | 同意ステータスがまだ決定されていない |
REQUIRED | 同意が必要(ポップアップが表示される) |
NOT_REQUIRED | 同意は不要(非GDPR地域) |
OBTAINED | すでに同意を取得済み |
デバッグ設定(テストモード)
開発中にGDPR/CCPA同意フローをテストしてください:
import {
AdropConsent,
AdropConsentDebugGeography,
} from 'adrop-ads-react-native'
// 同意リクエスト前にデバッグ地域を設定
// デバイスIDは自動的に検出される
AdropConsent.setDebugSettings(AdropConsentDebugGeography.EEA) // GDPRテスト
// テスト用に同意をリセット
AdropConsent.reset()
デバッグ地域
| 地域 | 説明 |
|---|
DISABLED | 実際のデバイス位置を使用 |
EEA | GDPRテスト(欧州経済領域) |
REGULATED_US_STATE | CCPAテスト(カリフォルニアなど) |
OTHER | 非規制地域テスト |
デバッグ設定は開発中のみ使用してください。本番リリース前に削除または無効化してください。
完全な例
import React, { useEffect, useState } from 'react'
import { View, Text, Button } from 'react-native'
import {
Adrop,
AdropConsent,
AdropConsentDebugGeography,
} from 'adrop-ads-react-native'
const App = () => {
const [consentStatus, setConsentStatus] = useState<string>('unknown')
useEffect(() => {
initializeConsent()
}, [])
const initializeConsent = async () => {
// まずAdropを初期化
await Adrop.initialize(false)
// 開発環境でデバッグ設定
if (__DEV__) {
AdropConsent.setDebugSettings(AdropConsentDebugGeography.EEA)
}
// 同意情報更新をリクエスト
const result = await AdropConsent.requestConsentInfoUpdate()
if (result.error) {
console.error('同意エラー:', result.error)
} else {
setConsentStatus(result.status ?? 'unknown')
}
}
const resetConsent = async () => {
await AdropConsent.reset()
await initializeConsent()
}
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>同意ステータス: {consentStatus}</Text>
{__DEV__ && (
<Button title="同意をリセット" onPress={resetConsent} />
)}
</View>
)
}
export default App
ベストプラクティス
早期リクエスト
SDK初期化直後、アプリライフサイクルの早い段階で同意を要求してください。
エラー処理
同意エラーを適切に処理し、フォールバック動作を提供してください。
全シナリオテスト
リリース前にデバッグ設定を使用してすべての同意シナリオをテストしてください。
ユーザー選択の尊重
同意を得たり拒否された後は、ユーザーの選択を尊重し、繰り返し要求しないでください。
関連ドキュメント