// Token: 0x0600032E RID: 814 RVA: 0x0000EF10 File Offset: 0x0000D310
        public AdLoaderClient(AdLoader unityAdLoader) : base("com.google.unity.ads.UnityCustomNativeAdListener")
        {
            AndroidJavaClass  androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject @static          = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity");

            this.adLoader = new AndroidJavaObject("com.google.unity.ads.NativeAdLoader", new object[]
            {
                @static,
                unityAdLoader.AdUnitId,
                this
            });
            this.CustomNativeTemplateCallbacks = unityAdLoader.CustomNativeTemplateClickHandlers;
            if (unityAdLoader.AdTypes.Contains(NativeAdType.CustomTemplate))
            {
                foreach (string text in unityAdLoader.TemplateIds)
                {
                    this.adLoader.Call("configureCustomNativeTemplateAd", new object[]
                    {
                        text,
                        this.CustomNativeTemplateCallbacks.ContainsKey(text)
                    });
                }
            }
            this.adLoader.Call("create", new object[0]);
        }
Exemple #2
0
    private void Awake()
    {
        if (nativeExpressAds)
        {
            DestroyImmediate(gameObject);
        }
        else
        {
            DontDestroyOnLoad(this.gameObject);
            nativeExpressAds = this;
            string id = (adID == null || adID == "" ? "ca-app-pub-6416530778400331/1695690401" : adID);
            adLoader = new AdLoader.Builder(id)
                       .ForNativeAppInstallAd()
                       .Build();

            adLoader.OnNativeAppInstallAdLoaded += this.HandleNativeAppInstallAdLoaded;
            adLoader.OnAdFailedToLoad           += this.HandleNativeAdFailedToLoad;
            RequestNativeAd();
            Hide();
            if (text != null)
            {
                text.text = "Awake";
            }
        }
    }
Exemple #3
0
            public void ShowAd(Activity context)
            {
                try
                {
                    Context             = context;
                    Template            = Context.FindViewById <TemplateView>(Resource.Id.my_template);
                    Template.Visibility = ViewStates.Gone;

                    var isPro = ListUtils.MyUserInfoList.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);
                }
            }
Exemple #4
0
        private void BindAdMob(Holders.AdMobAdapterViewHolder holder)
        {
            try
            {
                Template = holder.MianAlert;

                AdLoader.Builder builder = new AdLoader.Builder(holder.MainView.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());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public AdLoaderClient(AdLoader unityAdLoader)
        {
            this.adLoaderClientPtr = (IntPtr)GCHandle.Alloc(this);

            this.customNativeTemplateCallbacks = unityAdLoader.CustomNativeTemplateClickHandlers;
            string[] templateIdsArray = new string[unityAdLoader.TemplateIds.Count];
            unityAdLoader.TemplateIds.CopyTo(templateIdsArray);

            this.adTypes = new NativeAdTypes();
            if (unityAdLoader.AdTypes.Contains(NativeAdType.CustomTemplate))
            {
                adTypes.CustomTemplateAd = 1;
            }

            this.AdLoaderPtr = Externs.GADUCreateAdLoader(
                this.adLoaderClientPtr,
                unityAdLoader.AdUnitId,
                templateIdsArray,
                templateIdsArray.Length,
                ref adTypes);

            Externs.GADUSetAdLoaderCallbacks(
                this.AdLoaderPtr,
                AdLoaderDidReceiveNativeCustomTemplateAdCallback,
                AdLoaderDidFailToReceiveAdWithErrorCallback);
        }
        public AdLoaderClient(AdLoader unityAdLoader) : base(Utils.UnityAdLoaderListenerClassName)

        {
            AndroidJavaClass playerClass = new AndroidJavaClass(Utils.UnityActivityClassName);

            AndroidJavaObject activity =

                playerClass.GetStatic <AndroidJavaObject>("currentActivity");

            adLoader = new AndroidJavaObject(Utils.NativeAdLoaderClassName, activity,

                                             unityAdLoader.AdUnitId, this);

            this.CustomNativeTemplateCallbacks = unityAdLoader.CustomNativeTemplateClickHandlers;

            if (unityAdLoader.AdTypes.Contains(NativeAdType.CustomTemplate))

            {
                foreach (string templateId in unityAdLoader.TemplateIds)

                {
                    adLoader.Call("configureCustomNativeTemplateAd", templateId,

                                  this.CustomNativeTemplateCallbacks.ContainsKey(templateId));
                }
            }

            adLoader.Call("create");
        }
Exemple #7
0
            public void ShowAd(Activity context, TemplateView template = null)
            {
                try
                {
                    Context = context;

                    Template            = 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)
                {
                    Methods.DisplayReportResultTrack(e);
                }
            }
Exemple #8
0
            public void ShowAd(Context context)
            {
                try
                {
                    //ca-app-pub-3940256099942544/2247696110
                    // Methods in the NativeAdOptions.Builder class can be
                    // used here to specify individual options settings.

                    VideoOptions videoOptions = new VideoOptions.Builder()
                                                .SetStartMuted(false)
                                                .Build();

                    NativeAdOptions adOptions = new NativeAdOptions.Builder()
                                                .SetVideoOptions(videoOptions)
                                                .Build();

                    adLoader = new AdLoader.Builder(context, Settings.Ad_Native_Key)
                               .ForAppInstallAd(this).ForContentAd(this).WithAdListener(this).WithNativeAdOptions(adOptions)
                               .Build();

                    var adRequest = new AdRequest.Builder().Build();
                    adLoader.LoadAd(adRequest);
                }
                catch (Exception exception)
                {
                    Crashes.TrackError(exception);
                }
            }
Exemple #9
0
        private void GenerateBadges()
        {
            var days = AdLoader.LoadAds(SearchResultFolderPath, SearchStatusFolderPath);

            foreach (SearchDay day in days)
            {
                InstantiateBadge(day);
            }
        }
 public static IAdLoaderClient BuildAdLoaderClient(AdLoader adLoader)
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         return(new GoogleMobileAds.Android.AdLoaderClient(adLoader));
     }
     else
     {
         return(new GoogleMobileAds.Common.DummyClient());
     }
 }
Exemple #11
0
    public void setAdID(string adID)
    {
        appInstallAdLoaded = false;
        string id = adID;

        adLoader = new AdLoader.Builder(id)
                   .ForNativeAppInstallAd()
                   .Build();

        adLoader.OnNativeAppInstallAdLoaded += this.HandleNativeAppInstallAdLoaded;
        adLoader.OnAdFailedToLoad           += this.HandleNativeAdFailedToLoad;
        RequestNativeAd();
    }
Exemple #12
0
    private void Awake()
    {
        string id = (adsID == null || adsID == "" ? "ca-app-pub-6416530778400331/1695690401" : adsID);

        adLoader = new AdLoader.Builder(id)
                   .ForNativeAppInstallAd()
                   .Build();

        adLoader.OnNativeAppInstallAdLoaded += this.HandleNativeAppInstallAdLoaded;
        adLoader.OnAdFailedToLoad           += this.HandleNativeAdFailedToLoad;
        RequestNativeAd();

        createDialog();
    }
Exemple #13
0
        public void DidReceiveUnifiedNativeAd(AdLoader adLoader, UnifiedNativeAd nativeAd)
        {
            Console.WriteLine("Received Ad!");
            TemplateView templateView = View.NativeTemplate == AdMobNativeTemplates.Medium ?
                                        (TemplateView) new MediumTemplateView(Frame) : new SmallTemplateView(Frame);

            nativeAd.Delegate = this;
            SetNativeControl(templateView);

            templateView.SetNativeAd(nativeAd);
            templateView.AddHorizontalConstraintsToSuperviewWidth();
            templateView.AddVerticalCenterConstraintToSuperview();
            View?.TriggerAdRendered();
        }
 internal static IAdLoaderClient BuildAdLoaderClient(AdLoader adLoader)
 {
     #if UNITY_EDITOR
     // Testing UNITY_EDITOR first because the editor also responds to the currently
     // selected platform.
     return(new GoogleMobileAds.Common.DummyClient());
     #elif UNITY_ANDROID
     return(new GoogleMobileAds.Android.AdLoaderClient(adLoader));
     #elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
     return(new GoogleMobileAds.iOS.AdLoaderClient(adLoader));
     #else
     return(new GoogleMobileAds.Common.DummyClient());
     #endif
 }
Exemple #15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            ///Init ManagerAds
            adsMgr              = new AdsManager(ApplicationContext);
            txtStatusInter      = FindViewById <TextView>(Resource.Id.txtStateInterstitial);
            btnLoadInter        = FindViewById <Button>(Resource.Id.btnLoad);
            btnShowInter        = FindViewById <Button>(Resource.Id.btnShowInter);
            btnOpenActiveNative = FindViewById <Button>(Resource.Id.btnOpenNative);

            btnLoadInter.Click += BtnLoadInter_Click;
            btnShowInter.Click += BtnShowInter_Click;

            btnOpenActiveNative.Click += BtnOpenActiveNative_Click;

            //Implement Banner Ads
            var adview = FindViewById <AdView>(Resource.Id.adView);

            adsMgr.CreateAds(adview);

            var builder = new AdLoader.Builder(ApplicationContext, GetString(Resource.String.admobNative));
            var listen  = new AdsUnifiedLoadListening();

            listen.Ads_UnifiedNativeLoad += (obj, unifiedAds) =>
            {
                var          style = new NativeTemplateStyle.Builder().build();
                TemplateView view  = FindViewById <TemplateView>(Resource.Id.adviewTemplate);
                view.Visibility = ViewStates.Visible;
                view.SetStyles(style);
                view.SetNativeAd(unifiedAds);
            };
            builder.ForUnifiedNativeAd(listen);
            builder.WithAdListener(listen);
            builder.WithNativeAdOptions(new Android.Gms.Ads.Formats.NativeAdOptions.Builder().Build());

            AdLoader adloader = builder.Build();

            adloader.LoadAd(new AdRequest.Builder().Build());
            if (listen.Tag is null)
            {
                listen.Tag = adloader;
            }
        }
Exemple #16
0
        void CreateAdLoader()
        {
            if (View == null ||
                string.IsNullOrWhiteSpace(View.UnitId) ||
                View.AdMob == null)
            {
                return;
            }

            adLoader = new AdLoader(
                View.UnitId,
                ViewController,
                new[] { AdLoaderAdType.UnifiedNative },
                new[] { new AdLoaderOptions() });
            adLoader.Delegate = this;
        }
Exemple #17
0
        public void Initialize()
        {
            if (Loader != null)
            {
                throw new InvalidOperationException("AdAgent.Initialize() should only be called once.");
            }

            var multipleAds = new MultipleAdsAdLoaderOptions {
                NumberOfAds = 5
            };

            Loader = new AdLoader(UnitId, UIRuntime.NativeRootScreen as UIViewController,
                                  new[] { AdLoaderAdType.UnifiedNative }, new AdLoaderOptions[] { multipleAds })
            {
                Delegate = new IOSNativeAdListener(this)
            };
        }
Exemple #18
0
        public void CreateUnifiedAds(int numAds, AdsUnifiedLoadListening listen)
        {
            if (listen == null)
            {
                throw new ValidatingException("Not Implemented listener Unified");
            }
            var builder = new AdLoader.Builder(context, context.GetString(Resource.String.admobNative));

            builder.ForUnifiedNativeAd(listen);
            builder.WithAdListener(listen);
            builder.WithNativeAdOptions(new Android.Gms.Ads.Formats.NativeAdOptions.Builder().SetAdChoicesPlacement(5).Build());

            AdLoader adloader = builder.Build();

            adloader.LoadAds(new AdRequest.Builder().Build(), numAds);
            if (listen.Tag is null)
            {
                listen.Tag = adloader;
            }
        }
Exemple #19
0
        public void Initialize()
        {
            if (Loader != null)
            {
                throw new InvalidOperationException("AdAgent.Initialize() should only be called once.");
            }

            var builder = new AdLoader.Builder(UIRuntime.CurrentActivity, UnitId);

            builder.ForUnifiedNativeAd(new UnifiedNativeAdListener(this));

            var adOptions = new NativeAdOptions.Builder()
                            .SetVideoOptions(new VideoOptions.Builder().SetStartMuted(true).Build())
                            .Build();

            builder.WithNativeAdOptions(adOptions);

            builder.WithAdListener(new ZebbleAdListener(this));

            Loader = builder.Build();
        }
Exemple #20
0
        void CreateAdLoader()
        {
            var view = Element as AdMobNativeView;

            if (view == null ||
                string.IsNullOrWhiteSpace(view.UnitId) ||
                view.AdMob == null)
            {
                return;
            }

            var nativeAdOptionsBuilder = new NativeAdOptions.Builder();

            var adLoaderBuilder = new AdLoader.Builder(Context, view.UnitId);

            adLoaderBuilder
            .ForUnifiedNativeAd(this)
            .WithAdListener(new MyAdListener(this))
            .WithNativeAdOptions(nativeAdOptionsBuilder.Build());

            adLoader = adLoaderBuilder.Build();
        }
Exemple #21
0
 public static IAdLoaderClient BuildAdLoaderClient(AdLoader adLoader) =>
 new AdLoaderClient(adLoader);
Exemple #22
0
 public void DidFinishLoading(AdLoader adLoader)
 {
     View?.TriggerAdLoaded();
 }
Exemple #23
0
 public void DidFailToReceiveAd(AdLoader adLoader, RequestError error)
 {
     AdmobIOSListener.OnError(error, out var errorMessage);
     Agent.OnAdFailedToLoad(errorMessage);
 }
Exemple #24
0
 public void DidReceiveUnifiedNativeAd(AdLoader adLoader, UnifiedNativeAd nativeAd)
 {
     Agent.OnFetched(new NativeAdInfo(nativeAd));
 }
Exemple #25
0
 public void DidFailToReceiveAd(AdLoader adLoader, RequestError error)
 {
     View?.TriggerAdFailedToLoad((int)error.Code);
 }
 // Token: 0x06000771 RID: 1905 RVA: 0x0001F6E9 File Offset: 0x0001DAE9
 public static IAdLoaderClient BuildAdLoaderClient(AdLoader adLoader)
 {
     return(new AdLoaderClient(adLoader));
 }
 // Token: 0x060003AE RID: 942 RVA: 0x000109D5 File Offset: 0x0000EDD5
 internal static IAdLoaderClient BuildAdLoaderClient(AdLoader adLoader)
 {
     return(new AdLoaderClient(adLoader));
 }