> ## Documentation Index
> Fetch the complete documentation index at: https://docs.adrop.io/llms.txt
> Use this file to discover all available pages before exploring further.

# UMP連携

> GDPR/CCPA準拠のためのGoogle UMP連携

## 概要

UMP（User Messaging Platform）SDKは、GDPR（一般データ保護規則）およびCCPA（カリフォルニア消費者プライバシー法）準拠のために、パーソナライズド広告に対するユーザーの同意を管理します。

<Note>
  UMP連携には`adrop-ads-backfill`モジュールが必要です。[はじめに](/ja/sdk/android/overview)のインストールガイドを先に完了してください。
</Note>

***

## 基本的な使い方

Adrop初期化後にConsent Managerを使用してユーザーの同意を要求します。

<CodeGroup>
  ```kotlin Kotlin theme={null}
  import io.adrop.ads.Adrop
  import io.adrop.ads.consent.AdropConsentListener
  import io.adrop.ads.consent.AdropConsentResult

  class MainActivity : AppCompatActivity() {

      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)

          // Adrop.initialize()の後に呼び出し
          Adrop.consentManager?.requestConsentInfoUpdate(this, object : AdropConsentListener {
              override fun onConsentInfoUpdated(result: AdropConsentResult) {
                  if (result.error != null) {
                      Log.e("Consent", "エラー: ${result.error}")
                  }
              }
          })
      }
  }
  ```

  ```java Java theme={null}
  import io.adrop.ads.Adrop;
  import io.adrop.ads.consent.AdropConsentListener;
  import io.adrop.ads.consent.AdropConsentResult;

  public class MainActivity extends AppCompatActivity {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

          // Adrop.initialize()の後に呼び出し
          if (Adrop.getConsentManager() != null) {
              Adrop.getConsentManager().requestConsentInfoUpdate(this, new AdropConsentListener() {
                  @Override
                  public void onConsentInfoUpdated(AdropConsentResult result) {
                      if (result.getError() != null) {
                          Log.e("Consent", "エラー: " + result.getError());
                      }
                  }
              });
          }
      }
  }
  ```
</CodeGroup>

***

## 同意ステータス

Consent Managerは次のステータスのいずれかを返します：

| ステータス          | 説明                  |
| -------------- | ------------------- |
| `UNKNOWN`      | 同意ステータスがまだ決定されていない  |
| `REQUIRED`     | 同意が必要（ポップアップが表示される） |
| `NOT_REQUIRED` | 同意は不要（非GDPR地域）      |
| `OBTAINED`     | すでに同意を取得済み          |

***

## デバッグ設定（テストモード）

開発中にGDPR/CCPA同意フローをテストしてください：

<CodeGroup>
  ```kotlin Kotlin theme={null}
  import io.adrop.ads.consent.AdropConsentDebugGeography

  if (BuildConfig.DEBUG) {
      // 同意リクエスト前にデバッグ地域を設定
      Adrop.consentManager?.setDebugSettings(
          testDeviceHashedIds = listOf("YOUR_HASHED_DEVICE_ID"),  // Logcatで確認
          geography = AdropConsentDebugGeography.EEA  // GDPRテスト
      )

      // テスト用に同意状態をリセット
      Adrop.consentManager?.reset(this)
  }
  ```

  ```java Java theme={null}
  import io.adrop.ads.consent.AdropConsentDebugGeography;

  if (BuildConfig.DEBUG) {
      // 同意リクエスト前にデバッグ地域を設定
      Adrop.getConsentManager().setDebugSettings(
          Arrays.asList("YOUR_HASHED_DEVICE_ID"),  // Logcatで確認
          AdropConsentDebugGeography.EEA  // GDPRテスト
      );

      // テスト用に同意状態をリセット
      Adrop.getConsentManager().reset(this);
  }
  ```
</CodeGroup>

### デバッグ地域

| 地域                   | 説明                 |
| -------------------- | ------------------ |
| `DISABLED`           | 実際のデバイス位置を使用       |
| `EEA`                | GDPRテスト（欧州経済領域）    |
| `REGULATED_US_STATE` | CCPAテスト（カリフォルニアなど） |
| `OTHER`              | 非規制地域テスト           |

<Warning>
  デバッグ設定は開発中のみ使用してください。本番リリース前に削除または無効化してください。
</Warning>

***

## ベストプラクティス

<CardGroup cols={2}>
  <Card title="早期リクエスト" icon="clock">
    SDK初期化直後、アプリライフサイクルの早い段階で同意を要求してください。
  </Card>

  <Card title="エラー処理" icon="triangle-exclamation">
    同意エラーを適切に処理し、フォールバック動作を提供してください。
  </Card>

  <Card title="全シナリオテスト" icon="vial">
    リリース前にデバッグ設定を使用してすべての同意シナリオをテストしてください。
  </Card>

  <Card title="ユーザー選択の尊重" icon="user-check">
    同意を得たり拒否された後は、ユーザーの選択を尊重し、繰り返し要求しないでください。
  </Card>
</CardGroup>

***

## 関連ドキュメント

<CardGroup cols={2}>
  <Card title="ターゲティング" icon="bullseye" href="/ja/sdk/android/targeting">
    ユーザーおよびコンテキストターゲティング設定
  </Card>

  <Card title="はじめに" icon="rocket" href="/ja/sdk/android/overview">
    SDKインストールおよび設定ガイド
  </Card>

  <Card title="リファレンス" icon="book" href="/ja/sdk/android/reference">
    クラス、リスナー、エラーコード
  </Card>
</CardGroup>
