예제 #1
0
    private void ConfigureAds()
    {
        AppOptions appOptions = new AppOptions();

        appOptions.UserId        = PlayerData.Instance.PlayerId;
        appOptions.AdOrientation = AdOrientationType.AdColonyOrientationPortrait;
        string[] zoneIds = new string[1]
        {
            "vzc2600c4251094143b0"
        };
        Ads.Configure("appfe9ad9a3c19e49f38f", appOptions, zoneIds);
    }
예제 #2
0
        private void Configure()
        {
            if (mAdSettings == null)
            {
                Debug.LogWarning("Configuring AdColony with null settings.");
                return;
            }

            var appOptions = new AppOptions()
            {
                AdOrientation = ToAdColonyAdOrientation(mAdSettings.Orientation)
            };

            // Set GDPR consent (if any).
            // If there's no explicit consent given, this step is bypassed
            // which means the "pre-GDPR" configuring will be done.
            var consent = GetApplicableDataPrivacyConsent();

            if (consent != ConsentStatus.Unknown)
            {
                appOptions.GdprRequired      = true;
                appOptions.GdprConsentString = ToAdColonyConsentString(consent);
            }

            // Store all defined zone ids into a list.
            List <string> zoneIds = new List <string>
            {
                mAdSettings.DefaultInterstitialAdId.Id,
                mAdSettings.DefaultRewardedAdId.Id,
                mAdSettings.DefaultBannerAdId.Id
            };

            AddCustomZoneIDs(zoneIds, mAdSettings.CustomInterstitialAdIds);
            AddCustomZoneIDs(zoneIds, mAdSettings.CustomRewardedAdIds);
            AddCustomZoneIDs(zoneIds, mAdSettings.CustomBannerAdIds);
            Ads.Configure(
                mAdSettings.AppId.Id,
                appOptions,
                zoneIds.ToArray()
                );
        }
예제 #3
0
        /// <summary>
        /// Initializing AdColony
        /// </summary>
        /// <param name="consent">user consent -> if true show personalized ads</param>
        /// <param name="platformSettings">contains all required settings for this publisher</param>
        public void InitializeAds(UserConsent consent, UserConsent ccpaConsent, List <PlatformSettings> platformSettings)
        {
            debug = Advertisements.Instance.debug;

            //get settings
#if UNITY_ANDROID
            PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android);
#endif
#if UNITY_IOS
            PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS);
#endif
            //apply settings
            appId              = settings.appId.id;
            bannerZoneId       = settings.idBanner.id;
            interstitialZoneId = settings.idInterstitial.id;
            rewardedZoneId     = settings.idRewarded.id;

            //add listeners
            Ads.OnConfigurationCompleted            += OnConfigurationCompleted;
            Ads.OnRequestInterstitial               += OnRequestInterstitial;
            Ads.OnRequestInterstitialFailedWithZone += OnRequestInterstitialFailed;
            Ads.OnClosed             += OnClosed;
            Ads.OnRewardGranted      += OnRewardGranted;
            Ads.OnAdViewLoaded       += BannerLoaded;
            Ads.OnAdViewFailedToLoad += BannerLoadFailed;

            //preparing AdColony SDK for initialization
            AppOptions appOptions = new AppOptions();
            appOptions.AdOrientation = AdOrientationType.AdColonyOrientationAll;
            appOptions.GdprRequired  = true;
            if (consent == UserConsent.Unset || consent == UserConsent.Accept)
            {
                appOptions.GdprConsentString = "1";
            }
            else
            {
                appOptions.GdprConsentString = "0";
            }
            List <string> zoneIDs = new List <string>();
            if (!string.IsNullOrEmpty(bannerZoneId))
            {
                zoneIDs.Add(bannerZoneId);
            }
            if (!string.IsNullOrEmpty(interstitialZoneId))
            {
                zoneIDs.Add(interstitialZoneId);
            }
            if (!string.IsNullOrEmpty(rewardedZoneId))
            {
                zoneIDs.Add(rewardedZoneId);
            }

            if (zoneIDs.Count == 0)
            {
                Debug.LogError("Please add your IDs in SettingsWindow");
                return;
            }

            //Apply configuration
            Ads.Configure(appId, appOptions, zoneIDs.ToArray());

            //verify settings
            if (debug)
            {
                Debug.Log(this + " Initialize");
                ScreenWriter.Write(this + " Initialize");
                Debug.Log(this + " App ID: " + appId);
                ScreenWriter.Write(this + " App ID: " + appId);
                Debug.Log(this + " Banner Zone ID: " + bannerZoneId);
                ScreenWriter.Write(this + " Banner Zone ID: " + bannerZoneId);
                Debug.Log(this + " Interstitial Zone ID: " + interstitialZoneId);
                ScreenWriter.Write(this + " Interstitial Zone ID: " + interstitialZoneId);
                Debug.Log(this + " Rewarded Zone ID: " + rewardedZoneId);
                ScreenWriter.Write(this + " Rewarded Zone ID: " + rewardedZoneId);
            }
        }