Ejemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="adId"></param>
    /// <param name="onRewardEarned"></param>
    /// <returns>false если что то пошло не так. true если началась загрузка</returns>
    public static bool LoadRewardedAd(RewardedAdId adId, int tryReloadOnLoadingFailed = 0)
    {
        //Debug.Log($"advertising dubig is {debug}");

        ////это для тестирования
        //if (debug)
        //    adId = RewardedAdId.ID__TEST;

        var adCount = rewardedAds.Count(a => a.adId == adId);

        Debug.Log($"count of olready loaded advertising {adId} is: {adCount}. and max is: {GADWrapper.maximumSameRevardedAds}");

        if (adCount >= GADWrapper.maximumSameRevardedAds)
        {
            return(false);
        }

        var ad = new RewardedAd(Const.GetId(adId));

        rewardedAds.Add
        (
            new RewardedAdWrap()
        {
            adId = adId,
            ad   = ad,
            tryReloadOnLoadingFailed = tryReloadOnLoadingFailed
        }
        );

        ad.OnAdClosed         += Ad_OnAdClosed;
        ad.OnAdFailedToLoad   += Ad_OnAdFailedToLoad;
        ad.OnAdFailedToShow   += Ad_OnAdFailedToShow;
        ad.OnAdLoaded         += Ad_OnAdLoaded;
        ad.OnAdOpening        += Ad_OnAdOpening;
        ad.OnUserEarnedReward += Ad_OnUserEarnedReward;

        //Use AdRequest.Builder.addTestDevice("B36E541FF471B2ADC7410D9DEAC3A651") to get test ads on this device.
        ad.LoadAd(new AdRequest
                  .Builder()
                  .AddTestDevice("B36E541FF471B2ADC7410D9DEAC3A651")
                  .Build()
                  );

        return(true);
    }
Ejemplo n.º 2
0
    public static bool LoadInterstitialAd(InterstitialAdId adId, int tryReloadOnLoadingFailed = 0)
    {
        //это для тестирования
        //if (debug)
        //    adId = InterstitialAdId.ID__TEST;

        if (interAds.Where(rad => rad.adId == adId).ToList().Count >= GADWrapper.maximumSameInterstitialAds)
        {
            return(false);
        }

        var ad = new InterstitialAd(Const.GetId(adId));

        interAds.Add
        (
            new InterstitialAdWrap()
        {
            adId = adId,
            ad   = ad,
            tryReloadOnLoadingFailed = tryReloadOnLoadingFailed
        }
        );

        ad.OnAdClosed             += Ad_OnInterstitialAdClosed;
        ad.OnAdFailedToLoad       += Ad_OnInterstitialAdFailedToLoad;
        ad.OnAdLeavingApplication += Ad_OnInterstitialAdLeavingApplication;
        ad.OnAdLoaded             += Ad_OnInterstitialAdLoaded;
        ad.OnAdOpening            += Ad_OnInterstitialAdOpening;

        ad.LoadAd(new AdRequest
                  .Builder()
                  .AddTestDevice("B36E541FF471B2ADC7410D9DEAC3A651")
                  .Build()
                  );

        return(true);
    }