始める

Google の EU ユーザーの同意ポリシーに基づき、欧州経済領域(EEA)および英国のユーザーに対して特定の開示を行い、法的に義務付けられている場合に Cookie などのローカル ストレージを使用すること、および広告配信に個人データ(AdID など)を使用することについて同意を得る必要があります。このポリシーには、EU の e プライバシー指令と一般データ保護規則(GDPR)の要件が反映されています。

パブリッシャー様がこのポリシーで定められた義務を遂行できるよう、Google は User Messaging Platform(UMP)SDK を提供しています。UMP SDK は、最新の IAB 標準をサポートするように更新されました。これらの構成はすべて、[プライバシーとメッセージ] で AdMob 簡単に処理できます。

前提条件

メッセージ タイプを作成する

AdMobアカウントの [プライバシーとメッセージ] タブで、 利用可能なユーザー メッセージ のいずれかでユーザー メッセージを作成します。UMP SDK は、プロジェクトで設定された AdMob アプリケーション ID から作成されたユーザー メッセージを表示しようとします。アプリケーションにメッセージが構成されていない場合、SDK はエラーを返します。

詳しくは、 プライバシーとメッセージについてをご覧ください。

Update()を使用して、アプリが起動されるたびにユーザーの同意情報の更新をリクエストする必要があります。これにより、ユーザーがまだ同意していない場合や、同意の有効期限が切れている場合に、ユーザーが同意する必要があるかどうかが決まります。

アプリ起動時のステータスの確認方法の例を次に示します。

void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters();

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

void OnConsentInfoUpdated(FormError consentError)
{
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }

    // If the error is null, the consent information state was updated.
    // You are now ready to check if a form is available.
}

必要に応じて同意フォームを読み込んで表示する

最新の同意ステータスを取得したら、ConsentForm クラスのLoadAndShowConsentFormIfRequired() を呼び出して同意フォームを読み込みます。同意ステータスが必要な場合は、SDK によってフォームが読み込まれ、からすぐに表示されます。 Action<FormError> callback は、 フォームが閉じられると呼び出されます。同意が必要ない場合は、直ちに Action<FormError> callback が 呼び出されます。

void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters();

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

void OnConsentInfoUpdated(FormError consentError)
{
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }
    

    // If the error is null, the consent information state was updated.
    // You are now ready to check if a form is available.
    ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
    {
        if (formError != null)
        {
            // Consent gathering failed.
            UnityEngine.Debug.LogError(consentError);
            return;
        }

        // Consent has been gathered.
    });
}

ユーザーが選択またはフォームを閉じた後でアクションを実行する必要がある場合は、そのロジックをフォームの Action<FormError> callbackに配置します。

広告をリクエスト

アプリで広告をリクエストする前に、 CanRequestAds()を使用してユーザーから同意を得ているかどうかを確認してください。同意を取得する際には、次の 2 つの場所を確認します。

  1. 現在のセッションで同意が得られたら、
  2. Update()を呼び出した直後。前回のセッションで同意を取得した可能性があります。レイテンシに関するベスト プラクティスとして、コールバックの完了を待たずに、アプリの起動後できるだけ早く広告の読み込みを開始できるようにすることをおすすめします。

同意取得プロセス中にエラーが発生した場合でも、広告のリクエストを試みる必要があります。UMP SDK は前回のセッションの同意ステータスを使用します。

void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters();

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

void OnConsentInfoUpdated(FormError consentError)
{
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }

    // If the error is null, the consent information state was updated.
    // You are now ready to check if a form is available.
    ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
    {
        if (formError != null)
        {
            // Consent gathering failed.
            UnityEngine.Debug.LogError(consentError);
            return;
        }

        // Consent has been gathered.
        if (ConsentInformation.CanRequestAds())
        {
            MobileAds.Initialize((InitializationStatus initstatus) =>
            {
              // TODO: Request an ad.
            });
        }
    });
    
}

プライバシー設定

一部の同意フォームでは、ユーザーがいつでも同意を変更する必要があります。必要に応じて、次の手順に沿ってプライバシー オプション ボタンを実装してください。

手順は次のとおりです。

  1. アプリの設定ページのボタンなど、プライバシー オプション フォームをトリガーする UI 要素を実装します。
  2. LoadAndShowConsentFormIfRequired() が完了したら、PrivacyOptionsRequirementStatus を確認して、プライバシー オプション フォームを表示できる UI 要素を表示するかどうかを決定します。
  3. ユーザーが UI 要素を操作したら、ShowPrivacyOptionsForm() を呼び出してフォームを表示し、ユーザーがいつでもプライバシー オプションを更新できるようにします。

次の例は、Button からプライバシー オプション フォームを表示する方法を示しています。

[SerializeField, Tooltip("Button to show the privacy options form.")]
private Button _privacyButton;

private void Start()
{
  // Enable the privacy settings button.
  if (_privacyButton != null)
  {
      _privacyButton.onClick.AddListener(UpdatePrivacyButton);
      // Disable the privacy settings button by default.
      _privacyButton.interactable = false;
  }
}

/// <summary>
/// Shows the privacy options form to the user.
/// </summary>
public void ShowPrivacyOptionsForm()
{
    Debug.Log("Showing privacy options form.");

    ConsentForm.ShowPrivacyOptionsForm((FormError showError) =>
    {
        if (showError != null)
        {
            Debug.LogError("Error showing privacy options form with error: " + showError.Message);
        }
        // Enable the privacy settings button.
        if (_privacyButton != null)
        {
            _privacyButton.interactable =
                ConsentInformation.PrivacyOptionsRequirementStatus ==
                PrivacyOptionsRequirementStatus.Required;
        }
    });
}

テスト

開発中にアプリで統合をテストする場合は、次の手順に沿ってテストデバイスをプログラムに登録します。アプリをリリースする前に、これらのテストデバイス ID を設定するコードを必ず削除してください。

  1. Update()を呼び出します。
  2. ログ出力で、次の例のようなメッセージを確認します。このメッセージには、デバイス ID と、テストデバイスとして追加する方法が示されています。

    Android

    Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231")
    to set this as a debug device.
    

    iOS

    <UMP SDK>To enable debug mode for this device,
    set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
    
  3. テストデバイス ID をクリップボードにコピーします。

  4. コードを変更して、 呼び出しDebugGeography.TestDeviceHashedIds を設定し、 テストデバイス ID のリストを渡します。

    void Start()
    {
        var debugSettings = new ConsentDebugSettings
        {
            TestDeviceHashedIds =
            new List<string>
            {
                "TEST-DEVICE-HASHED-ID"
            }
        };
    
        // Create a ConsentRequestParameters object.
        ConsentRequestParameters request = new ConsentRequestParameters
        {
            ConsentDebugSettings = debugSettings,
        };
    
        // Check the current consent information status.
        ConsentInformation.Update(request, OnConsentInfoUpdated);
    }
    

地域を強制的に適用する

UMP SDK では、 the DebugGeography field on ConsentDebugSettingsを使用して、デバイスが EEA または英国にあるかのようにアプリの動作をテストできます。デバッグ設定はテストデバイスでのみ機能します。

void Start()
{
    var debugSettings = new ConsentDebugSettings
    {
        // Geography appears as in EEA for debug devices.
        DebugGeography = DebugGeography.EEA,
        TestDeviceHashedIds = new List<string>
        {
            "TEST-DEVICE-HASHED-ID"
        }
    };

    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters
    {
        ConsentDebugSettings = debugSettings,
    };

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

UMP SDK でアプリをテストする場合は、SDK の状態をリセットして、ユーザーの最初のインストール エクスペリエンスをシミュレートすると便利です。SDK には、これを行うための Reset() メソッドが用意されています。

ConsentInformation.Reset();