Google User Messaging Platform (UMP) SDK는 개인 정보 보호 옵션을 관리하는 데 도움이 되는 개인 정보 보호 및 메시지 도구입니다. 자세한 내용은 개인 정보 보호 및 메시지에 대한 정보를 참고하세요.
메시지 유형 만들기
AdMob 계정의 개인 정보 보호 및 메시지 탭에서 사용 가능한 사용자 메시지 유형 중 하나를 사용하여 사용자 메시지를 만듭니다. UMP SDK는 프로젝트에 설정된 AdMob 애플리케이션 ID에서 생성된 개인 정보 보호 메시지를 표시하려고 시도합니다.
자세한 내용은 개인 정보 보호 및 메시지에 대한 정보를 참고하세요.
사용자의 동의 정보 가져오기
앱을 실행할 때마다 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 the error is null, the consent information state was updated.
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }
}
개인 정보 보호 메시지 양식을 로드하고 표시
최신 동의 상태를 수신한 후 LoadAndShowConsentFormIfRequired()를 호출하여 사용자 동의를 수집하는 데 필요한 양식을 로드합니다. 로드가 완료되면 양식이 즉시 표시됩니다.
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.
    });
}
개인 정보 보호 옵션
일부 개인 정보 보호 메시지 양식은 게시자가 렌더링한 개인 정보 보호 옵션 진입점에서 표시되므로 사용자가 언제든지 개인 정보 보호 옵션을 관리할 수 있습니다. 개인 정보 보호 옵션 진입점에서 사용자에게 표시되는 메시지에 대해 자세히 알아보려면 사용 가능한 사용자 메시지 유형을 참고하세요.
개인 정보 보호 옵션 진입점을 구현하려면 다음 단계를 완료하세요.
- Update()를 호출한 후- PrivacyOptionsRequirementStatus를 확인하여 개인 정보 보호 옵션 진입점이 필요한지 확인합니다.
- 필요한 경우 개인 정보 보호 옵션 진입점으로 사용할 수 있는 표시되고 상호작용 가능한 UI 요소를 앱에 추가합니다. 개인 정보 보호 진입점이 필요하지 않은 경우 UI 요소가 표시되지 않고 상호작용할 수 없도록 구성합니다.
- ShowPrivacyOptionsForm()를 사용하여 개인 정보 보호 옵션 양식을 표시합니다.
다음 코드 예는 이러한 단계를 보여줍니다.
[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.
        UpdatePrivacyButton();
    });
}
/// <summary>
/// Updates the privacy buttons visual state based on the consent information.
/// </summary>
void UpdatePrivacyButton()
{
    if (_privacyButton != null)
    {
        _privacyButton.interactable =
            ConsentInformation.PrivacyOptionsRequirementStatus ==
                PrivacyOptionsRequirementStatus.Required;
    }
}
사용자 동의를 얻어 광고 요청
광고를 요청하기 전에 
CanRequestAds()를 사용하여 사용자로부터 동의를 얻었는지 확인합니다.
동의를 수집하는 동안 광고를 요청할 수 있는지 확인해야 하는 위치는 다음과 같습니다.
- UMP SDK가 현재 세션에서 동의를 수집한 후
- Update()를 호출한 직후 UMP SDK가 이전 앱 세션에서 동의를 얻었을 수 있습니다.
동의 수집 과정에서 오류가 발생하면 광고를 요청할 수 있는지 확인하세요. 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.
            });
        }
    });
    
}
테스트
개발하면서 앱의 통합을 테스트하려는 경우에는 다음 단계에 따라 테스트 기기를 프로그래매틱 방식으로 등록하세요. 앱을 출시하기 전에 이러한 테스트 기기 ID를 설정하는 코드를 반드시 삭제하세요.
- Update()를 호출합니다.
- 로그 출력에서 기기 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]
- 테스트 기기 ID를 클립보드에 복사합니다. 
- 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는 DebugGeography를 사용하여 기기가 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();
GitHub의 예
이 페이지에서 다루는 UMP SDK 통합의 전체 예는 HelloWorld를 참고하세요.