예제 #1
0
        private static IEnumerator ShowAd(AdType type)
        {
            while (!Monetization.isInitialized)
            {
                yield return(new WaitForSeconds(.2f));
            }
            while (!Monetization.IsReady(type.ToString()))
            {
                yield return(new WaitForSeconds(.2f));
            }

            var ad = Monetization.GetPlacementContent(type.ToString());

            if (ad == null)
            {
                Debug.LogError("Ad retrieved was null.");
                yield break;
            }
            while (!ad.ready)
            {
                yield return(new WaitForSeconds(.2f));
            }
            yield return((ad as ShowAdPlacementContent).Show());


            Debug.LogError("Passed show ad");
            yield return(null);
        }
예제 #2
0
        private AdFlags GetFlag(AdType adType)
        {
            switch (adType)
            {
            case AdType.Banner:
                return(AdFlags.Banner);

            case AdType.Interstitial:
                return(AdFlags.Interstitial);

            case AdType.Rewarded:
                return(AdFlags.Rewarded);

#pragma warning disable CS0618 // Type or member is obsolete
            case AdType.Native:
                return(AdFlags.Native);

#pragma warning restore CS0618 // Type or member is obsolete
            case AdType.None:
                return(AdFlags.None);

            default:
                throw new NotImplementedException("Unknown adType " + adType.ToString());
            }
        }
        public void SendAdClicked(AdType type)
        {
            AdjustEvent adjustEvent = new AdjustEvent(Constants.Analytics.AdjustEvents.AdClick);

            adjustEvent.addPartnerParameter("type", $"{type.ToString()}");
            Adjust.trackEvent(adjustEvent);
        }
예제 #4
0
 public void onLoaded()
 {
     if (CASFactory.isDebug)
     {
         Debug.Log("[CleverAdsSolutions] onLoaded " + adType.ToString());
     }
     CASFactory.ExecuteEvent(OnAdLoaded);
 }
        public void SendAdResult(AdResultType result, AdType type, AdSourceType adSource)
        {
            if (ShouldSkipSendEvent)
            {
                DebugLog($"[ANALYTICS] [Skip] AD EVENT: {MapAdResult(result).ToString()} {MapAdSource(adSource).ToString()}, {MapAdType(type).ToString()}");
                return;
            }

            QLAdEvent adEvent = new QLAdEvent(MapAdResult(result), MapAdType(type), MapAdSource(adSource));

            TrackEvent(adEvent);

            if (result == AdResultType.Watched)
            {
                AdjustEvent adjustEvent = new AdjustEvent(Constants.Analytics.AdjustEvents.AdImpression);
                adjustEvent.addPartnerParameter("type", $"{type.ToString()}");
                adjustEvent.addPartnerParameter("eCPM", "0.0");
                Adjust.trackEvent(adjustEvent);
                DebugLog($"[ADJUST] AD WATCHED - {adjustEvent.ToString()} - {type.ToString()}");
            }
        }
예제 #6
0
    // Returns if ad was played
    public bool PlayAdIfEnabled(AdType t)
    {
        Debug.Log("Ads controller recieved request to play ad of type: " + t.ToString());

        AdFetchIfNeeded();

        // If it's not a rewarded video then we do the callback even if ad failed
        if (t != AdType.rewardedVideo)
        {
            CallbackAfterAdd(true);
        }

        if ((t == AdType.rewardedVideo) || adsEnabled)
        {
            if (t == AdType.rewardedVideo && adCallback == null)
            {
                Debug.LogError("Rewarded video request has no callback.");
            }
            if (!IsMobile())
            {
                PlayAdDebug();
                if (t == AdType.rewardedVideo)
                {
                    CallbackAfterAdd(true);
                }
            }
            else
            {
                if (t == AdType.rewardedVideo && IsRewardedAvailable())
                {
                    Debug.Log("PlayAdIfEnabled - rewarded");
                    return(PlayRewardedVideoMobile());
                }
                else if (t == AdType.interstitial && IsInterstitialAvailable())
                {
                    PlayAdInterstitialMobile();
                    return(true);
                }
                else
                {
                    Debug.LogError("Ad type not handled: " + t);
                    return(false);
                }
            }

            return(true);
        }
        // Rewarded video failed
        else
        {
            return(false);
        }
    }
예제 #7
0
    void Start()
    {
#if UNITY_ANDROID
        Advertisement.Initialize(gameID, false);
#elif UNITY_EDITOR
        Advertisement.Initialize(gameID, true);
#endif

        adCallback = new ShowOptions();
        adCallback.resultCallback = ResultAds;

        type = currentTypeAds.ToString();
    }
예제 #8
0
        public void Fetch(AdType adType)
        {
            switch (adType)
            {
            case AdType.Interstitial:

                if (!SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.Player.HasRemovedAds)
                {
                    Debug.Log("[ADS] [ADMOB] Fetch - ad type: " + adType.ToString());
                    Crashlytics.Log($"[ADMOB] Fetch interstitial");
                    interstitialUtilities.CheckInternet(AdFailRetryTime, RequestInterstitial, RefetchInterstitial);
                }
                break;

            case AdType.RewardedVideo:

                Debug.Log("[ADS] [ADMOB] Fetch - ad type: " + adType.ToString());
                Crashlytics.Log($"[ADMOB] Fetch rewarded video");
                rewardedUtilities.CheckInternet(AdFailRetryTime, RequestRewardBasedVideo, RefetchRewardedVideo);
                break;
            }
        }
예제 #9
0
        public AdUnitViewModel(AdType type, int position)
        {
            Position = position;
            string typeStr = type.ToString().ToLower();

            // Set uniqueId as ad-bigbox-1
            UniqueId = string.Format("ad-{0}-{1}", typeStr, position);
            Sizes    = WebContext.Current.AdSlotSizes[type];
            // Set css class as ad-bigbox
            if (type != AdType.Leaderboard)
            {
                CssClass = string.Format("ad-{0} ad-labeled", typeStr);
            }
            else
            {
                CssClass = string.Format("ad-{0}", typeStr);
            }
        }
예제 #10
0
        void ProviderListDrawer(AdType adType, List <ProviderID> networkIds)
        {
            EditorGUILayout.BeginHorizontal();
            ReorderableListGUI.Title(adType.ToString());

            var allIds = Enum.GetValues(typeof(ProviderID));

            if (GUILayout.Button("Add", GUILayout.Width(70)))
            {
                foreach (ProviderID networkId in allIds)
                {
                    if (IsSuportAd(networkId, adType) && !networkIds.Contains(networkId))
                    {
                        networkIds.Add(networkId);
                        break;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            ReorderableListGUI.ListField(networkIds, ProviderItemDrawer, DrawEmptyProvider, ReorderableListFlags.HideAddButton);
        }
예제 #11
0
        public void ShowAds(AdType adType, string zone = "")
        {
            Debug.Log("AdMobSdk::ShowAds, adType = " + adType.ToString());
            switch (adType)
            {
            case AdType.Banner:
                bannerView.Show();
                break;

            case AdType.Interstitial:
                if (interstitial.IsLoaded())
                {
                    interstitial.Show();
                }
                break;

            case AdType.VideoRewardAd:
                if (RewardBasedVideoAd.Instance.IsLoaded())
                {
                    RewardBasedVideoAd.Instance.Show();
                }
                break;
            }
        }
예제 #12
0
 /// <summary>
 /// Called when <paramref name="adType"/> has failed to load
 /// </summary>
 /// <param name="adType"></param>
 private void OnAdLoadFailed(AdType adType)
 {
     OnLog(string.Format("Ads failed request for: {0}", adType.ToString()));
     if (!_failedAdTypes.Contains(adType))
     {
         _failedAdTypes.Add(adType);
     }
     Invalidate();
 }
예제 #13
0
 /// <summary>
 /// Called when <paramref name="adType"/> has succeeded to load
 /// </summary>
 /// <param name="adType"></param>
 private void OnAdLoadSucceeded(AdType adType)
 {
     OnLog(string.Format("Ads being successfully served for: {0}", adType.ToString()));
     if (_failedAdTypes.Contains(adType))
     {
         _failedAdTypes.Remove(adType);
     }
 }
예제 #14
0
 private void RemoveAdFromFailedAds(AdType AdType)
 {
     _settings.RemoveAdFromFailedAds(AdType);
     OnLog(string.Format("Ads failed request for: {0}", AdType.ToString()));
 }
예제 #15
0
 private void RemoveAdFromFailedAds(AdType AdType)
 {
     _settings.RemoveAdFromFailedAds(AdType);
     OnLog(string.Format("Ads failed request for: {0}", AdType.ToString()));
 }
예제 #16
0
 private void TrackFlurryAnalytics(AdType adType, string eventDescription)
 {
     if (!string.IsNullOrEmpty(FlurryAnalyticsId))
     {
         if (FlurryAnalyticsControl != null)
         {
             reflectionHelper.TryInvokeMethod(FlurryAnalyticsControlType, null, "LogEvent", new object[] { String.Format("AdRotator: {0} for AdType: {1}", eventDescription, adType.ToString()) });
         }
     }
 }
예제 #17
0
 private void TrackGoogleAnalytics(AdType adType, string eventDescription)
 {
     if (!string.IsNullOrEmpty(GoogleAnalyticsId))
     {
         if (GoogleAnalyticsControl != null)
         {
             reflectionHelper.TryInvokeMethod(GoogleAnalyticsControlType, GoogleAnalyticsControl, "TrackEvent", new object[] { "AdRotator", eventDescription, adType.ToString(), 0 });
         }
     }
 }
예제 #18
0
        private bool IsAdTypeValid(AdType adType)
        {
            switch (adType)
            {
                case AdType.PubCenter:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsPubCenterValid.ToString()));
                    return IsPubCenterValid;
                case AdType.AdDuplex:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsAdDuplexValid.ToString()));
                    return IsAdDuplexValid;
#if(!WP8)
                    case AdType.AdMob:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsAdMobValid.ToString()));
                    return IsAdMobValid;
                case AdType.MobFox:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsMobFoxValid.ToString()));
                    return IsMobFoxValid;
#endif
#if(!NONLOCATION)
                case AdType.Smaato:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsSmaatoValid.ToString()));
                    return IsSmaatoValid;
#endif
                case AdType.InnerActive:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsInnerActiveValid.ToString()));
                    return IsInnerActiveValid;
                case AdType.DefaultHouseAd:
                    OnLog(string.Format("Testing \"{0}\" - Result {1}", adType.ToString(), IsDefaultHouseAdValid.ToString()));
                    return IsDefaultHouseAdValid;

            }
            //Davide Cleopadre www.cleosolutions.com
            //if for any reason the AdType cannot be found is not valid
            //if we add new ads type the control will continue to work
            //also not updated
            return false;
        }