From c5ea2565b7cf2f1f860eeeb872097680a061ff04 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Mon, 18 Nov 2024 07:17:19 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 697616850 --- .../GoogleMobileAdsConsentManager.m | 31 ++++++++++++------- .../GoogleMobileAdsConsentManager.swift | 8 +++-- .../GoogleMobileAdsConsentManager.swift | 8 +++-- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Objective-C/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.m b/Objective-C/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.m index dc9611f6..605326f0 100644 --- a/Objective-C/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.m +++ b/Objective-C/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.m @@ -52,26 +52,35 @@ - (void)gatherConsentFromConsentPresentationViewController:(UIViewController *)v // debugSettings.geography = UMPDebugGeographyEEA; parameters.debugSettings = debugSettings; - // [START gather_consent] + // [START request_consent_info_update] // Requesting an update to consent information should be called on every app launch. [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable requestConsentError) { + // [START_EXCLUDE] if (requestConsentError) { consentGatheringComplete(requestConsentError); } else { - [UMPConsentForm - loadAndPresentIfRequiredFromViewController:viewController - completionHandler:^( - NSError - *_Nullable loadAndPresentError) { - // Consent has been gathered. - consentGatheringComplete( - loadAndPresentError); - }]; + [self loadAndPresentIfRequiredFromViewController:viewController + completionHandler:consentGatheringComplete]; } + // [END_EXCLUDE] }]; - // [END gather_consent] + // [END request_consent_info_update] +} + +- (void)loadAndPresentIfRequiredFromViewController:(UIViewController *)viewController + completionHandler:(void (^)(NSError *_Nullable))completionHandler { + // [START load_and_present_consent_form] + [UMPConsentForm + loadAndPresentIfRequiredFromViewController:viewController + completionHandler:^(NSError *_Nullable loadAndPresentError) { + // Consent gathering process is complete. + // [START_EXCLUDE silent] + completionHandler(loadAndPresentError); + // [END_EXCLUDE] + }]; + // [END load_and_present_consent_form] } - (void)presentPrivacyOptionsFormFromViewController:(UIViewController *)viewController diff --git a/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift b/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift index 7b43d383..ab69cd27 100644 --- a/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift +++ b/Swift/admob/BannerExample/BannerExample/GoogleMobileAdsConsentManager.swift @@ -49,25 +49,29 @@ class GoogleMobileAdsConsentManager: NSObject { // debugSettings.geography = UMPDebugGeography.EEA parameters.debugSettings = debugSettings - // [START gather_consent] + // [START request_consent_info_update] // Requesting an update to consent information should be called on every app launch. UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) { requestConsentError in + // [START_EXCLUDE] guard requestConsentError == nil else { return consentGatheringComplete(requestConsentError) } Task { @MainActor in do { + // [START load_and_present_consent_form] try await UMPConsentForm.loadAndPresentIfRequired(from: viewController) + // [END load_and_present_consent_form] // Consent has been gathered. consentGatheringComplete(nil) } catch { consentGatheringComplete(error) } } + // [END_EXCLUDE] } - // [END gather_consent] + // [END request_consent_info_update] } /// Helper method to call the UMP SDK method to present the privacy options form. diff --git a/Swift/advanced/SwiftUIDemo/SwiftUIDemo/Supporting-Files/GoogleMobileAdsConsentManager.swift b/Swift/advanced/SwiftUIDemo/SwiftUIDemo/Supporting-Files/GoogleMobileAdsConsentManager.swift index 648a38ed..9b07b907 100644 --- a/Swift/advanced/SwiftUIDemo/SwiftUIDemo/Supporting-Files/GoogleMobileAdsConsentManager.swift +++ b/Swift/advanced/SwiftUIDemo/SwiftUIDemo/Supporting-Files/GoogleMobileAdsConsentManager.swift @@ -46,25 +46,29 @@ class GoogleMobileAdsConsentManager: NSObject { // debugSettings.geography = UMPDebugGeography.EEA parameters.debugSettings = debugSettings - // [START gather_consent] + // [START request_consent_info_update] // Requesting an update to consent information should be called on every app launch. UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) { requestConsentError in + // [START_EXCLUDE] guard requestConsentError == nil else { return consentGatheringComplete(requestConsentError) } Task { @MainActor in do { + // [START load_and_present_consent_form] try await UMPConsentForm.loadAndPresentIfRequired(from: nil) + // [END load_and_present_consent_form] // Consent has been gathered. consentGatheringComplete(nil) } catch { consentGatheringComplete(error) } } + // [END_EXCLUDE] } - // [END gather_consent] + // [END request_consent_info_update] } /// Helper method to call the UMP SDK method to present the privacy options form.