スタートガイド

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

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

Prerequisites

ユーザー メッセージの種類

サポートされているメッセージの一覧については、 ユーザー メッセージの種類 をご覧ください。各メッセージ タイプを実装する具体的な手順については、左側のナビゲーション バーをご覧ください。

メッセージを表示する必要があるかどうかを判断する

フォームを読み込む前に Update() を使用して、アプリの起動ごとにユーザーの同意情報の更新をリクエストする必要があります。これにより、ユーザーがまだ同意していない場合またはユーザーの同意の有効期限が切れている場合に、同意を提示する必要があるかどうかを判断できます。

必要な場合は、フォームを提示する際に、 ConsentInformationオブジェクトに保存されている情報を使用します。

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

using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Ump;
using GoogleMobileAds.Ump.Api;

public class UmpManager : MonoBehaviour
{
    void Start()
    {
        // Set tag for under age of consent.
        // Here false means users are not under age.
        ConsentRequestParameters request = new ConsentRequestParameters
        {
            TagForUnderAgeOfConsent = false,
        };

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

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

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

利用可能な場合にフォームを読み込む

フォームを表示する前に、フォームが利用可能かどうかを判断する必要があります。このフォームを利用できないのは、ユーザーが制限付きの広告トラッキングを有効にしているか、「同意年齢に満たない」としてタグ付けされている場合です。

フォームが利用可能かどうかを確認するには、先ほど作成したthe IsConsentFormAvailable() method on the ConsentInformation instance を使用します。

次に、ラッパー メソッドを追加して、フォームを読み込みます。

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

    // If the error is null, the consent information state was updated.
    // You are now ready to check if a form is available.
    if (ConsentInformation.IsConsentFormAvailable())
    {
        LoadConsentForm();
    }
}

void LoadConsentForm()
{
    // Loads a consent form.
}

フォームを読み込むには、 the static Load() method on the ConsentForm classを使用します。

private ConsentForm _consentForm;

void LoadConsentForm()
{
    // Loads a consent form.
    ConsentForm.Load(OnLoadConsentForm);
}

void OnLoadConsentForm(ConsentForm consentForm, FormError error)
{
    if (error != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(error);
        return;
    }

    // The consent form was loaded.
    // Save the consent form for future requests.
    _consentForm = consentForm;

    // You are now ready to show the form.
}

必要に応じてフォームを提示する

フォームが利用可能であることを確認して読み込みが完了したら、ConsentForm インスタンスのShow() メソッドを使用してフォームを提示します。

前述のConsentInformation オブジェクトを使用してconsent status を確認し、LoadForm() メソッドを更新します。

void LoadForm()
{
    // Loads a consent form.
    ConsentForm.Load(OnLoadConsentForm);
}

void OnLoadConsentForm(ConsentForm consentForm, FormError error)
{
    if (error != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(error);
        return;
    }

    // The consent form was loaded.
    // Save the consent form for future requests.
    _consentForm = consentForm;

    // You are now ready to show the form.
    if(ConsentInformation.ConsentStatus == ConsentStatus.Required)
    {
        _consentForm.Show(OnShowForm);
    }
}

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

    // Handle dismissal by reloading form.
    LoadForm();
}

ユーザーが選択を行うかフォームを拒否した後になんらかのアクションを行う必要がある場合は、そのロジックをフォームの完了ハンドラまたはコールバックに配置します。

テスト

地域を強制的に適用する

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

デバッグ機能を使用するには、アプリのデバッグ設定でテスト用デバイスのハッシュ ID を指定する必要があります。この値を設定せずにUpdate() を呼び出すと、実行時に必要な ID ハッシュがログに記録されます。

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"
        }
    };

    // Set tag for under age of consent.
    // Here false means users are not under age.
    ConsentRequestParameters request = new ConsentRequestParameters
    {
        TagForUnderAgeOfConsent = false,
        ConsentDebugSettings = debugSettings,
    };

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

DebugGeography enumを使用すると、次のいずれかのオプションに地域を強制的に適用できます。

デバッグ地域 説明
DISABLED 地域デバッグが無効になっています。
EEA デバッグ用デバイスで、地域が EEA として表示されます。
Not_EEA デバッグ用デバイスで、地域が EEA として表示されません。

デバッグ設定はテスト用デバイスでのみ機能します。エミュレータはデフォルトでテストが有効になっているため、デバイス ID リストに追加する必要はありません。

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

ConsentInformation.Reset();

UMP SDK をプロジェクトから完全に削除する場合は、 Reset() も呼び出す必要があります。