Ejemplo n.º 1
0
        /// <summary>
        /// Initializing Chartboost
        /// </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;
            if (debug)
            {
                Debug.Log(this + " " + "Start Initialization");
                ScreenWriter.Write(this + " " + "Start Initialization");
            }

            //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
            chartboostAppId        = settings.appId.id;
            chartboostAppSignature = settings.idInterstitial.id;

            CBSettings.setAppId(chartboostAppId, chartboostAppSignature);
            gameObject.AddComponent <Chartboost>();

            //preparing Chartboost SDK for initialization
            if (consent == UserConsent.Deny)
            {
                Chartboost.addDataUseConsent(CBGDPRDataUseConsent.NoBehavioral);
            }
            else
            {
                Chartboost.addDataUseConsent(CBGDPRDataUseConsent.Behavioral);
            }

            if (ccpaConsent == UserConsent.Deny)
            {
                Chartboost.addDataUseConsent(CBCCPADataUseConsent.OptOutSale);
            }
            else
            {
                Chartboost.addDataUseConsent(CBCCPADataUseConsent.OptInSale);
            }

            //add listeners
            Chartboost.didFailToLoadInterstitial  += FailInterstitial;
            Chartboost.didCacheInterstitial       += InterstitialLoaded;
            Chartboost.didDismissInterstitial     += ReloadInterstitial;
            Chartboost.didCompleteRewardedVideo   += RewardedVideoCompleted;
            Chartboost.didFailToLoadRewardedVideo += FailRewarded;
            Chartboost.didCacheRewardedVideo      += RewardedLoaded;
            Chartboost.didDismissRewardedVideo    += ReloadRewarded;
            Chartboost.didInitialize += InitializationSuccess;

            //start loading ads
            LoadInterstitial();
            LoadRewardedVideo();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates consent at runtime
        /// </summary>
        /// <param name="consent">the new consent</param>
        public void UpdateConsent(UserConsent consent, UserConsent ccpaConsent)
        {
            if (consent == UserConsent.Deny)
            {
                Chartboost.addDataUseConsent(CBGDPRDataUseConsent.NoBehavioral);
            }
            else
            {
                Chartboost.addDataUseConsent(CBGDPRDataUseConsent.Behavioral);
            }

            if (ccpaConsent == UserConsent.Deny)
            {
                Chartboost.addDataUseConsent(CBCCPADataUseConsent.OptOutSale);
            }
            else
            {
                Chartboost.addDataUseConsent(CBCCPADataUseConsent.OptInSale);
            }

            Debug.Log(this + " Update consent to " + consent);
            ScreenWriter.Write(this + " Update consent to " + consent);
        }