メインコンテンツへスキップ

概要

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)
  }
}

AdropConsentResult

requestConsentInfoUpdate()は以下の結果タイプを返します:
interface AdropConsentResult {
  status: AdropConsentStatus
  canRequestAds: boolean
  canShowPersonalizedAds: boolean
  error?: string
}
フィールドタイプ説明
statusAdropConsentStatus現在の同意ステータス
canRequestAdsboolean広告リクエストが可能かどうか
canShowPersonalizedAdsbooleanパーソナライズド広告を表示できるかどうか
errorstringエラーメッセージ(ある場合)

AdropConsentStatus

enum AdropConsentStatus {
  UNKNOWN = 0,
  REQUIRED = 1,
  NOT_REQUIRED = 2,
  OBTAINED = 3,
}
ステータス説明
UNKNOWN0同意ステータスがまだ決定されていない
REQUIRED1同意が必要(ポップアップが表示される)
NOT_REQUIRED2同意は不要(非GDPR地域)
OBTAINED3すでに同意を取得済み

デバッグ設定(テストモード)

開発中にGDPR/CCPA同意フローをテストしてください:
import {
  AdropConsent,
  AdropConsentDebugGeography,
} from 'adrop-ads-react-native'

// 同意リクエスト前にデバッグ地域を設定
// デバイスIDは自動的に検出される
AdropConsent.setDebugSettings(AdropConsentDebugGeography.EEA)  // GDPRテスト

// テスト用に同意をリセット
AdropConsent.reset()

デバッグ地域

地域説明
DISABLED実際のデバイス位置を使用
EEAGDPRテスト(欧州経済領域)
REGULATED_US_STATECCPAテスト(カリフォルニアなど)
OTHER非規制地域テスト
デバッグ設定は開発中のみ使用してください。本番リリース前に削除または無効化してください。

追加メソッド

getConsentStatus

static getConsentStatus(): Promise<AdropConsentStatus>
現在の同意ステータスを返します。

canRequestAds

static canRequestAds(): Promise<boolean>
現在広告リクエストが可能かどうかを返します。

完全な例

import React, { useEffect, useState } from 'react'
import { View, Text, Button } from 'react-native'
import {
  Adrop,
  AdropConsent,
  AdropConsentStatus,
  AdropConsentDebugGeography,
} from 'adrop-ads-react-native'

const App = () => {
  const [consentStatus, setConsentStatus] = useState<AdropConsentStatus>(
    AdropConsentStatus.UNKNOWN
  )

  useEffect(() => {
    initializeConsent()
  }, [])

  const initializeConsent = async () => {
    // まずAdropを初期化
    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)
    }
  }

  const resetConsent = async () => {
    AdropConsent.reset()
    await initializeConsent()
  }

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>同意ステータス: {AdropConsentStatus[consentStatus]}</Text>
      {__DEV__ && (
        <Button title="同意をリセット" onPress={resetConsent} />
      )}
    </View>
  )
}

export default App

ベストプラクティス

早期リクエスト

SDK初期化直後、アプリライフサイクルの早い段階で同意を要求してください。

エラー処理

同意エラーを適切に処理し、フォールバック動作を提供してください。

全シナリオテスト

リリース前にデバッグ設定を使用してすべての同意シナリオをテストしてください。

ユーザー選択の尊重

同意を得たり拒否された後は、ユーザーの選択を尊重し、繰り返し要求しないでください。

関連ドキュメント