Exemple #1
0
        public static void InitNative(Activity activity, LinearLayout nativeAdLayout, NativeAd ad)
        {
            try
            {
                if (AppSettings.ShowFbNativeAds)
                {
                    InitializeFacebook.Initialize(activity);

                    if (ad == null)
                    {
                        var nativeAd = new NativeAd(activity, AppSettings.AdsFbNativeKey);
#pragma warning disable 618
                        nativeAd.SetAdListener(new NativeAdListener(activity, nativeAd, nativeAdLayout));
#pragma warning restore 618

                        // Initiate a request to load an ad.
                        nativeAd.LoadAd();
                    }
                    else
                    {
                        var holder = new AdHolder(nativeAdLayout);
                        LoadAd(activity, holder, ad, nativeAdLayout);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Exemple #2
0
        public static InterstitialAd InitInterstitial(Activity activity)
        {
            try
            {
                if (AppSettings.ShowFbInterstitialAds)
                {
                    if (CountInterstitial == AppSettings.ShowAdMobInterstitialCount)
                    {
                        InitializeFacebook.Initialize(activity);

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

                        #pragma warning disable 618
                        interstitialAd.SetAdListener(new MyInterstitialAdListener(activity, interstitialAd));
                        #pragma warning restore 618
                        // Request an ad
                        interstitialAd.LoadAd();

                        return(interstitialAd);
                    }

                    CountInterstitial++;
                }
                return(null !);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(null !);
            }
        }
Exemple #3
0
        public static RewardedVideoAd InitRewardVideo(Activity activity)
        {
            try
            {
                if (AppSettings.ShowFbRewardVideoAds)
                {
                    if (CountRewarded == AppSettings.ShowAdMobRewardedVideoCount)
                    {
                        InitializeFacebook.Initialize(activity);

                        CountRewarded = 0;

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

                       #pragma warning disable 618
                        rewardVideoAd.SetAdListener(new MyRRewardVideoAdListener(activity, rewardVideoAd));
                       #pragma warning restore 618
                        rewardVideoAd.LoadAd();
                        //RewardVideoAd.SetRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD"));

                        return(rewardVideoAd);
                    }

                    CountRewarded++;
                }
                return(null !);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(null !);
            }
        }
Exemple #4
0
        public static AdView InitAdView(Activity activity, LinearLayout adContainer)
        {
            try
            {
                if (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);

                    #pragma warning disable 618
                    adView.SetAdListener(new BannerAdListener());
                    #pragma warning restore 618
                    // Request an ad
                    adView.LoadAd();

                    return(adView);
                }
                return(null !);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(null !);
            }
        }
        public static InterstitialAd InitInterstitial(Activity activity)
        {
            try
            {
                if (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);
            }
        }
        public static RewardedVideoAd InitRewardVideo(Activity activity)
        {
            try
            {
                if (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);
            }
        }
        public static AdView InitAdView(Activity activity, LinearLayout adContainer)
        {
            try
            {
                if (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);
            }
        }