public void ApplySelectedYear() { gameObject.SetActive(false); var audience = ConsentClient.SetYearOfBirth(selectedYear); if (audience == Audience.Children) { OnUnderAgeOfConsent.Invoke(); } else { OnConsentRequired.Invoke(); } }
public void ApplyMediationConsent() { if (!initialized) { return; } gameObject.SetActive(false); var result = new char[items.Length]; var decline = false; for (int i = 0; i < items.Length; i++) { if (items[i] == null) { result[i] = '-'; } else if (items[i].isAccepted) { result[i] = '1'; } else { result[i] = '0'; decline = true; } } if (decline) { PlayerPrefs.SetString(ConsentClient.consentStringPref, new string( result )); MobileAds.settings.userConsent = ConsentStatus.Denied; } else { PlayerPrefs.SetString(ConsentClient.consentStringPref, ConsentClient.consentAccepted); MobileAds.settings.userConsent = ConsentStatus.Accepted; } initialized = false; PlayerPrefs.Save(); ConsentClient.SetMediationExtras(); OnConsent.Invoke(); }
public void Init(ConsentRequestParameters parameters) { this.parameters = parameters; var language = Application.systemLanguage; bool requiredAudienceDefinition = parameters.withAudienceDefinition && (parameters.resetStatus == 2 || ConsentClient.GetYearOfBirth() < 0); if (audienceDefinition) { audienceDefinition.gameObject.SetActive(requiredAudienceDefinition); audienceDefinition.OnConsentRequired.AddListener(ShowConsentPanel); audienceDefinition.OnUnderAgeOfConsent.AddListener(OnConsentDenied); } else { requiredAudienceDefinition = false; } consentTextContainer.gameObject.SetActive(!requiredAudienceDefinition); if (mediationSettings) { mediationSettings.gameObject.SetActive(false); mediationSettings.OnConsent.AddListener(OnMediationSettingsApplied); if (parameters.settingsTogglePrefab) { mediationSettings.policyPrefab = parameters.settingsTogglePrefab; } if (mediationSettingsBtn) { mediationSettingsBtn.gameObject.SetActive(parameters.withMediationSettings); mediationSettingsBtn.onClick.AddListener(OnOpenOptions); } } if (acceptBtn) { acceptBtn.gameObject.SetActive(true); acceptBtn.onClick.AddListener(OnConsentAccepted); } if (declineBtn) { declineBtn.gameObject.SetActive(parameters.withDeclineOption); declineBtn.onClick.AddListener(OnConsentDenied); } if (privacyPolicyBtn) { if (!string.IsNullOrEmpty(parameters.GetPrivacyPolicyUrl(Application.platform))) { privacyPolicyBtn.gameObject.SetActive(true); privacyPolicyBtn.onClick.AddListener(OnOpenCompanyPrivacyPolicy); } else { privacyPolicyBtn.gameObject.SetActive(false); } } if (termsOfUseBtn) { if (!string.IsNullOrEmpty(parameters.GetTermsOfUseUrl(Application.platform))) { termsOfUseBtn.gameObject.SetActive(true); termsOfUseBtn.onClick.AddListener(OnOpenTermsOfUse); } else { termsOfUseBtn.gameObject.SetActive(false); } } }
/// <summary> /// Request user consent. /// Returns UI otherwise NULL when consent has already been obtained. /// </summary> /// <exception cref="NullReferenceException">Consent Request require UserConsentUI prefab!</exception> public UserConsentUI Present() { return(ConsentClient.Request(this)); }
/// <summary> /// User tagged audience. /// If the user has not chosen a year of birth yet then return <see cref="Audience.Mixed"/>. /// </summary> public static Audience GetAudience() { return(ConsentClient.GetAudience(ConsentClient.GetYearOfBirth())); }
/// <summary> /// User latest selected year of birth. /// If the user has not chosen a year of birth yet then return -1. /// </summary> public static int GetYearOfBirth() { return(ConsentClient.GetYearOfBirth()); }
/// <summary> /// User latest consent status values. /// If the user has not consent yet then return <see cref="ConsentStatus.Undefined"/>. /// </summary> public static ConsentStatus GetStatus() { return(ConsentClient.GetStatus()); }