Exemple #1
0
            public void ShowAd(Activity context)
            {
                try
                {
                    Context             = context;
                    Template            = Context.FindViewById <TemplateView>(Resource.Id.my_template);
                    Template.Visibility = ViewStates.Gone;

                    if (AppSettings.ShowAdMobNative)
                    {
                        AdLoader.Builder builder = new AdLoader.Builder(Context, AppSettings.AdAdMobNativeKey);
                        builder.ForUnifiedNativeAd(this);
                        VideoOptions videoOptions = new VideoOptions.Builder()
                                                    .SetStartMuted(true)
                                                    .Build();
                        NativeAdOptions adOptions = new NativeAdOptions.Builder()
                                                    .SetVideoOptions(videoOptions)
                                                    .Build();

                        builder.WithNativeAdOptions(adOptions);

                        AdLoader adLoader = builder.WithAdListener(new AdListener()).Build();
                        adLoader.LoadAd(new AdRequest.Builder().Build());
                    }
                    else
                    {
                        Template.Visibility = ViewStates.Gone;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
Exemple #2
0
            public void ShowAd(Activity context, View view)
            {
                try
                {
                    View    = view;
                    Context = context;

                    if (View != null)
                    {
                        Template = View.FindViewById <TemplateView>(Resource.Id.my_template);
                    }
                    else
                    {
                        Template = Context.FindViewById <TemplateView>(Resource.Id.my_template);
                    }

                    Template.Visibility = ViewStates.Gone;

                    var isPro = ListUtils.MyUserInfo.FirstOrDefault()?.IsPro ?? "0";
                    if (isPro == "0" && AppSettings.ShowAdMobNative)
                    {
                        AdLoader.Builder builder = new AdLoader.Builder(Context, AppSettings.AdAdMobNativeKey);
                        builder.ForUnifiedNativeAd(this);
                        VideoOptions videoOptions = new VideoOptions.Builder()
                                                    .SetStartMuted(true)
                                                    .Build();
                        NativeAdOptions adOptions = new NativeAdOptions.Builder()
                                                    .SetVideoOptions(videoOptions)
                                                    .Build();

                        builder.WithNativeAdOptions(adOptions);

                        AdLoader adLoader = builder.WithAdListener(new AdListener()).Build();
                        adLoader.LoadAd(new AdRequest.Builder().Build());
                    }
                    else
                    {
                        Template.Visibility = ViewStates.Gone;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }