private AdRequest CreateAdMobAdRequest() { AdRequest.Builder adBuilder = new AdRequest.Builder(); // Targeting settings. var targeting = mAdSettings.TargetingSettings; // Child-directed. if (targeting.TagForChildDirectedTreatment != AdChildDirectedTreatment.Unspecified) { adBuilder.TagForChildDirectedTreatment(targeting.TagForChildDirectedTreatment == AdChildDirectedTreatment.Yes); } // Extras. if (targeting.ExtraOptions != null) { foreach (var extra in targeting.ExtraOptions) { if (!string.IsNullOrEmpty(extra.Key) && !string.IsNullOrEmpty(extra.Value)) { adBuilder.AddExtra(extra.Key, extra.Value); } } } // Test mode. if (mAdSettings.EnableTestMode) { // Add all emulators adBuilder.AddTestDevice(AdRequest.TestDeviceSimulator); // Add user-specified test devices for (int i = 0; i < mAdSettings.TestDeviceIds.Length; i++) { adBuilder.AddTestDevice(Util.AutoTrimId(mAdSettings.TestDeviceIds[i])); } } // Configure the ad request to serve non-personalized ads. // The default behavior of the Google Mobile Ads SDK is to serve personalized ads, // we only do this if the user has explicitly denied to grant consent. // https://developers.google.com/admob/unity/eu-consent if (mCurrentConsent == ConsentStatus.Revoked) { adBuilder.AddExtra(mNonPersonalizedPair.Key, mNonPersonalizedPair.Value); } return(adBuilder.Build()); }
public static AdRequest BuildRequest(TDAdConfig data) { var builder = new AdRequest.Builder(); if (m_Config.isDebugMode) { builder.AddTestDevice("54A21F94407E31BD8A20879613096F8B"); } if (!string.IsNullOrEmpty(data.keyword)) { builder.AddKeyword(data.keyword); } builder.SetGender((Gender)data.gender); if (data.isBirthDayConfiged) { builder.SetBirthday(data.GetBirthDayTime()); } if (data.forFamilies) { builder.AddExtra("is_designed_for_families", "true"); } if (data.forChild) { builder.TagForChildDirectedTreatment(true); } return(builder.Build()); }
private AdRequest.Builder CreateRequestBuilder() { AdRequest.Builder requestBuilder = new AdRequest.Builder(); if (!servePersonalizedAds) { requestBuilder.AddExtra("npa", "1"); } var isChildDirected = adMobConfig?.ChildDirected ?? false; Debug.Log("ServePersonalizedAds: " + servePersonalizedAds); Debug.Log("ChildDirected: " + isChildDirected); if (isChildDirected) { requestBuilder .TagForChildDirectedTreatment(true) .AddExtra("tag_for_under_age_of_consent", "true") .AddExtra("max_ad_content_rating", "G"); } adMobConfig?.TestDevices?.ForEach(td => requestBuilder.AddTestDevice(td)); return(requestBuilder); }
public static AdRequest BuildAdRequest() { var builder = new AdRequest.Builder(); foreach (var deviceId in UM_GoogleAdsSettings.Instance.TestDevices) { builder.AddTestDevice(deviceId); } foreach (var keyword in UM_GoogleAdsSettings.Instance.Keywords) { builder.AddKeyword(keyword); } builder.TagForChildDirectedTreatment(UM_GoogleAdsSettings.Instance.TagForChildDirectedTreatment); if (UM_GoogleAdsSettings.Instance.NPA) { builder.AddExtra("npa", "1"); } if (UM_GoogleAdsSettings.Instance.Gender != Gender.Unknown) { builder.SetGender(UM_GoogleAdsSettings.Instance.Gender); } if (UM_GoogleAdsSettings.Instance.Birthday != DateTime.MinValue) { builder.SetBirthday(UM_GoogleAdsSettings.Instance.Birthday); } return(builder.Build()); }
private AdRequest CreateAdMobAdRequest() { AdRequest.Builder adBuilder = new AdRequest.Builder(); // Targeting settings. var targeting = globalAdSettings.AdMobTargeting; // Gender. if (targeting.gender != AdSettings.TargetGender.Unspecified) { adBuilder.SetGender( targeting.gender == AdSettings.TargetGender.Male ? GoogleMobileAds.Api.Gender.Male : GoogleMobileAds.Api.Gender.Female ); } // Birthday. if (targeting.setBirthday) { adBuilder.SetBirthday(targeting.birthday); } // Child-directed. if (targeting.tagForChildDirectedTreatment != AdSettings.ChildDirectedTreatmentOption.Unspecified) { adBuilder.TagForChildDirectedTreatment(targeting.tagForChildDirectedTreatment == AdSettings.ChildDirectedTreatmentOption.Yes); } // Extras. if (targeting.extras != null) { foreach (var extra in targeting.extras) { if (!string.IsNullOrEmpty(extra.key) && !string.IsNullOrEmpty(extra.value)) { adBuilder.AddExtra(extra.key, extra.value); } } } // Test mode. if (globalAdSettings.AdMobEnableTestMode) { // Add all emulators adBuilder.AddTestDevice(AdRequest.TestDeviceSimulator); // Add user-specified test devices for (int i = 0; i < globalAdSettings.AdMobTestDeviceIds.Length; i++) { adBuilder.AddTestDevice(Helper.AutoTrimId(globalAdSettings.AdMobTestDeviceIds[i])); } } return(adBuilder.Build()); }
AdRequest SetupNewAdRequest() { var request = new AdRequest.Builder(); foreach (var testDevice in TestDevices) { request.AddTestDevice(testDevice); } foreach (var keyword in KeyWords) { request.AddKeyword(keyword); } request.TagForChildDirectedTreatment(TagForChildDirectedTreatment); request.AddExtra("color_bg", ColorHelper.HexString((Color)BackgroundColor)); request.SetBirthday(Birthday); return(request.Build()); }
// Returns an ad request with custom ad targeting. Modified to be more dynamic and adjustable from editor. private AdRequest CreateAdRequest() { AdRequest.Builder adRequestBuilder = new AdRequest.Builder(); if (testConfiguration.testDevicesEnabled == true) { adRequestBuilder.AddTestDevice(AdRequest.TestDeviceSimulator); foreach (string s in testConfiguration.testDevices) { adRequestBuilder.AddTestDevice(s); } } foreach (string s in keyWords) { adRequestBuilder.AddKeyword(s); } if (targetAudience.genderConfig.enable == true) { adRequestBuilder.SetGender(targetAudience.genderConfig.gender); } if (targetAudience.birthday.enable == true) { adRequestBuilder.SetBirthday(new DateTime(targetAudience.birthday.year, targetAudience.birthday.month, targetAudience.birthday.day)); } if (targetAudience.TagForChildDirectedTreatment.enable == true) { switch (targetAudience.TagForChildDirectedTreatment.yesNo) { case E_YES_NO.yes: adRequestBuilder.TagForChildDirectedTreatment(true); break; case E_YES_NO.no: adRequestBuilder.TagForChildDirectedTreatment(false); break; default: //don't add option break; } } if (targetAudience.tag_for_under_age_of_consent.enable == true) { switch (targetAudience.tag_for_under_age_of_consent.yesNo) { case E_YES_NO.yes: adRequestBuilder.AddExtra("tag_for_under_age_of_consent", "true"); break; case E_YES_NO.no: adRequestBuilder.AddExtra("tag_for_under_age_of_consent", "false"); break; default: //don't add option break; } } if (targetAudience.max_ad_content_rating.enable == true) { adRequestBuilder.AddExtra("max_ad_content_rating", targetAudience.max_ad_content_rating.ToString()); mPrint("max_ad_content_rating:'" + targetAudience.max_ad_content_rating.ToString() + "'."); } return(adRequestBuilder.Build()); /*return new AdRequest.Builder() * .AddTestDevice(AdRequest.TestDeviceSimulator) * .AddTestDevice("0123456789ABCDEF0123456789ABCDEF") * .AddKeyword("game") * .SetGender(Gender.Male) * .SetBirthday(new DateTime(1985, 1, 1)) * .TagForChildDirectedTreatment(false) * .AddExtra("color_bg", "9B30FF") * .Build();*/ }