Ejemplo n.º 1
0
        public static RewardedVideoAd InitRewardVideo(Activity activity)
        {
            try
            {
                var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0;
                if (isPro == 0 && AppSettings.ShowFbRewardVideoAds)
                {
                    if (CountRewarded == AppSettings.ShowAdMobRewardedVideoCount)
                    {
                        InitializeFacebook.Initialize(activity);

                        CountRewarded = 0;

                        var rewardVideoAd = new RewardedVideoAd(activity, AppSettings.AdsFbRewardVideoKey);

                        rewardVideoAd.SetAdListener(new MyRRewardVideoAdListener(activity, rewardVideoAd));
                        rewardVideoAd.LoadAd();
                        //RewardVideoAd.SetRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD"));

                        return(rewardVideoAd);
                    }

                    CountRewarded++;
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static InterstitialAd InitInterstitial(Activity activity)
        {
            try
            {
                var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0;
                if (isPro == 0 && AppSettings.ShowFbInterstitialAds)
                {
                    if (CountInterstitial == AppSettings.ShowAdMobInterstitialCount)
                    {
                        InitializeFacebook.Initialize(activity);

                        CountInterstitial = 0;
                        var interstitialAd = new InterstitialAd(activity, AppSettings.AdsFbInterstitialKey);

                        interstitialAd.SetAdListener(new MyInterstitialAdListener(activity, interstitialAd));
                        // Request an ad
                        interstitialAd.LoadAd();

                        return(interstitialAd);
                    }

                    CountInterstitial++;
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Ejemplo n.º 3
0
        public static AdView InitAdView(Activity activity, LinearLayout adContainer)
        {
            try
            {
                var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0;
                if (isPro == 0 && AppSettings.ShowFbBannerAds)
                {
                    InitializeFacebook.Initialize(activity);

                    AdView adView = new AdView(activity, AppSettings.AdsFbBannerKey, AdSize.BannerHeight50);
                    // Add the ad view to your activity layout
                    adContainer.AddView(adView);

                    adView.SetAdListener(new BannerAdListener());
                    // Request an ad
                    adView.LoadAd();

                    return(adView);
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }