AdMobConsentBridge.cs 991 B

1234567891011121314151617181920212223242526272829303132
  1. #if CRAZY_FRUIT_ADMOB
  2. using System;
  3. using GoogleMobileAds.Ump.Api;
  4. using UnityEngine;
  5. /// <summary>UMP consent gate before the Mobile Ads SDK may load ads (EEA / UK / CH).</summary>
  6. public static class AdMobConsentBridge
  7. {
  8. public static void RunConsentGate(Action<bool> onComplete)
  9. {
  10. var request = new ConsentRequestParameters();
  11. ConsentInformation.Update(request, updateError =>
  12. {
  13. if (updateError != null)
  14. {
  15. Debug.LogWarning("[AdMob] Consent update failed: " + updateError.Message);
  16. onComplete?.Invoke(ConsentInformation.CanRequestAds());
  17. return;
  18. }
  19. ConsentForm.LoadAndShowConsentFormIfRequired(showError =>
  20. {
  21. if (showError != null)
  22. Debug.LogWarning("[AdMob] Consent form: " + showError.Message);
  23. onComplete?.Invoke(ConsentInformation.CanRequestAds());
  24. });
  25. });
  26. }
  27. }
  28. #endif