From a81c23e2570cd6f77da4d05ea2fef13a36bcb183 Mon Sep 17 00:00:00 2001 From: Interactive Media Ads Developer Relations Date: Mon, 18 Nov 2024 07:17:19 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 697616850 --- .../v3/samples/umpimaapp/ConsentManager.java | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java b/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java index 577f5f8..1d90a34 100644 --- a/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java +++ b/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java @@ -36,15 +36,12 @@ public boolean canRequestAds() { return consentInformation.canRequestAds(); } - // [START is_privacy_options_required] /** Helper function to determine if a privacy options entry point is required. */ public boolean isPrivacyOptionsRequired() { return consentInformation.getPrivacyOptionsRequirementStatus() == PrivacyOptionsRequirementStatus.REQUIRED; } - // [END is_privacy_options_required] - /** Load remote updates of consent messages and gather previously cached user consent. */ public void gatherConsent(OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { // For testing purposes, you can force a DebugGeography of EEA or NOT_EEA. @@ -68,16 +65,34 @@ public void gatherConsent(OnConsentGatheringCompleteListener onConsentGatheringC .setConsentDebugSettings(debugSettings) .build(); - // [START gather_consent] + // [START request_consent_info_update] // Requesting an update to consent information should be called on every app launch. consentInformation.requestConsentInfoUpdate( activity, params, - () -> - UserMessagingPlatform.loadAndShowConsentFormIfRequired( - activity, onConsentGatheringCompleteListener::consentGatheringComplete), - onConsentGatheringCompleteListener::consentGatheringComplete); - // [END gather_consent] + () -> // Called when consent information is successfully updated. + // [START_EXCLUDE silent] + loadAndShowConsentFormIfRequired(activity, onConsentGatheringCompleteListener), + // [END_EXCLUDE] + requestConsentError -> // Called when there's an error updating consent information. + // [START_EXCLUDE silent] + onConsentGatheringCompleteListener.consentGatheringComplete(requestConsentError)); + // [END_EXCLUDE] + // [END request_consent_info_update] + } + + private void loadAndShowConsentFormIfRequired( + Activity activity, OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { + // [START load_and_show_consent_form] + UserMessagingPlatform.loadAndShowConsentFormIfRequired( + activity, + formError -> { + // Consent gathering process is complete. + // [START_EXCLUDE silent] + onConsentGatheringCompleteListener.consentGatheringComplete(formError); + // [END_EXCLUDE] + }); + // [END load_and_show_consent_form] } /** Shows a form to app users for collecting their consent. */