예제 #1
0
        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);
        }
예제 #2
0
        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());
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }
        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());
        }
예제 #6
0
        public static AdRequest.Builder GetRequest()
        {
            bool   addBundle      = false;
            Bundle bundleExtra    = new Bundle();
            var    requestBuilder = new AdRequest.Builder();

            if (CrossMTAdmob.Current.TestDevices != null)
            {
                foreach (var testDevice in CrossMTAdmob.Current.TestDevices)
                {
                    requestBuilder.AddTestDevice(testDevice);
                }
            }

            if (!CrossMTAdmob.Current.UserPersonalizedAds)
            {
                bundleExtra.PutString("npa", "1");
                addBundle = true;
            }

            if (CrossMTAdmob.Current.UseRestrictedDataProcessing)
            {
                bundleExtra.PutString("rdp", "1");
                addBundle = true;
            }

            if (CrossMTAdmob.Current.ComplyWithFamilyPolicies)
            {
                requestBuilder.TagForChildDirectedTreatment(CrossMTAdmob.Current.ComplyWithFamilyPolicies);
                bundleExtra.PutString("max_ad_content_rating", "G");
                addBundle = true;
            }

            if (CrossMTAdmob.Current.CustomParameters.Count > 0)
            {
                foreach (KeyValuePair <string, string> param in CrossMTAdmob.Current.CustomParameters)
                {
                    bundleExtra.PutString(param.Key, param.Value);
                }
                addBundle = true;
            }

            if (addBundle)
            {
                requestBuilder = requestBuilder.AddNetworkExtrasBundle(Java.Lang.Class.FromType(typeof(AdMobAdapter)), bundleExtra);
            }

            return(requestBuilder);
        }
예제 #7
0
    private AdRequest ReklamIstegiOlustur()
    {
        AdRequest.Builder reklamIstegi = new AdRequest.Builder();

        if (testModu && !string.IsNullOrEmpty(testDeviceID))
        {
            reklamIstegi.AddTestDevice(testDeviceID);
        }

        if (cocuklaraYonelikReklamGoster)
        {
            reklamIstegi.TagForChildDirectedTreatment(true);
        }

        return(reklamIstegi.Build());
    }
예제 #8
0
    AdRequest ReklamIstegiOlustur(bool testModu)
    {
        AdRequest.Builder reklamIstegi = new AdRequest.Builder();

        if (testModu)
        {
            reklamIstegi.AddTestDevice(AdRequest.TestDeviceSimulator).AddTestDevice(testDeviceID);
        }

        if (cocuklaraYonelikReklamGoster)
        {
            reklamIstegi.TagForChildDirectedTreatment(true).AddExtra("is_designed_for_families", "true");
        }

        return(reklamIstegi.Build());
    }
예제 #9
0
        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());
        }
예제 #10
0
    private AdRequest GenerateAdRequest()
    {
        AdRequest.Builder AdBuilder = new AdRequest.Builder();

        AdBuilder.AddTestDevice(AdRequest.TestDeviceSimulator);         // Marks emulators as testers

        // Add all of our TestDeviceIds as test devices if we're in test mode
        if (EnableTestMode)
        {
            foreach (string CurDeviceId in TestDeviceIds)
            {
                AdBuilder.AddTestDevice(CurDeviceId);
            }
        }
        AdBuilder.TagForChildDirectedTreatment(TagForChildDirectedTreatment);

        return(AdBuilder.Build());
    }
예제 #11
0
    public void BuildInterstitial()
    {
        failedLoading = false;
        interstitial  = new InterstitialAd(adUnitID);
        // Events
        interstitial.AdClosed          += HandleInterstitialClosed;
        interstitial.AdClosing         += HandleInterstitialClosing;
        interstitial.AdFailedToLoad    += HandleInterstitialFailedToLoad;
        interstitial.AdLeftApplication += HandleLeftApplication;
        interstitial.AdLoaded          += HandleLoaded;
        interstitial.AdOpened          += HandleOpened;
        // AdRequest
        AdRequest.Builder builder = new AdRequest.Builder();
        if (useEmulatorAsATestDevice)
        {
            builder.AddTestDevice(AdRequest.TestDeviceSimulator);
        }
        if (testDeviceIDs != null && testDeviceIDs.Length > 0)
        {
            foreach (string testDeviceID in testDeviceIDs)
            {
                builder.AddTestDevice(testDeviceID);
            }
        }
        if (keywords != null && keywords.Length > 0)
        {
            foreach (string keyword in keywords)
            {
                builder.AddKeyword(keyword);
            }
        }
        if (gender.HasValue)
        {
            builder.SetGender(gender.Value);
        }
        if (childDirectedTreatment.HasValue)
        {
            builder.TagForChildDirectedTreatment(childDirectedTreatment.Value);
        }
        AdRequest request = builder.Build();

        interstitial.LoadAd(request);
    }
예제 #12
0
    private AdRequest getAdRequest()
    {
        // Creating the request builder
        AdRequest.Builder requestBuilder = new AdRequest.Builder();

        // Test devices
        if (useEmulatorAsATestDevice)
        {
            requestBuilder.AddTestDevice(AdRequest.TestDeviceSimulator);
        }
        foreach (string deviceID in testDevices)
        {
            if (!string.IsNullOrEmpty(deviceID))
            {
                requestBuilder.AddTestDevice(deviceID);
            }
        }

        // Keywords
        string[] words = keywords.Split(',');
        foreach (string word in words)
        {
            if (word.Trim() != string.Empty)
            {
                requestBuilder.AddKeyword(word.Trim());
            }
        }

        // Gender
        if (gender != Gender.Unknown)
        {
            requestBuilder.SetGender(gender);
        }

        // Tag for child directed treatment
        if (tagForChildDirectedTreatment != TagForChildDirectedTreatment.NotTagged)
        {
            requestBuilder.TagForChildDirectedTreatment(tagForChildDirectedTreatment == TagForChildDirectedTreatment.True);
        }

        return(requestBuilder.Build());
    }
예제 #13
0
        private AdView CreateAdView()
        {
            var adView = new AdView(Context)
            {
                AdSize   = AdSize.SmartBanner,
                AdUnitId = Element.AdUnitId
            };

            adView.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            Bundle extras = new Bundle();

            extras.PutString(MAX_AD_CONTENT_RATING, AD_CONTENT_RATING_G);

            AdRequest.Builder builder = new AdRequest.Builder();
            builder.AddNetworkExtrasBundle(Java.Lang.Class.FromType(typeof(AdMobAdapter)), extras);
            builder.TagForChildDirectedTreatment(true);

            AdRequest request = builder.Build();

            adView.LoadAd(request);

            return(adView);
        }
예제 #14
0
    // 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();*/
    }