예제 #1
0
        public void onCustomClick(AndroidJavaObject ad, string assetName)
        {
            CustomNativeTemplateAd nativeAd = new CustomNativeTemplateAd(
                new CustomNativeTemplateClient(ad));

            MobileAdsEventExecutor.executeInUpdate(() =>
                                                   this.CustomNativeTemplateCallbacks[nativeAd.GetCustomTemplateId()](nativeAd, assetName));
        }
        private static void NativeCustomTemplateDidReceiveClickCallback(
            IntPtr nativeCustomAd, string assetName)
        {
            CustomNativeTemplateClient client = IntPtrToAdLoaderClient(nativeCustomAd);

            if (client.clickHandler != null)
            {
                CustomNativeTemplateAd nativeAd = new CustomNativeTemplateAd(client);
                MobileAdsEventExecutor.executeInUpdate(() => client.clickHandler(nativeAd, assetName));
            }
        }
예제 #3
0
        // Creates an InterstitialAd.
        public InterstitialAd(string adUnitId)
        {
            Type googleMobileAdsClientFactory = Type.GetType(
                "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp");
            MethodInfo method = googleMobileAdsClientFactory.GetMethod(
                "BuildInterstitialClient",
                BindingFlags.Static | BindingFlags.Public);

            this.client = (IInterstitialClient)method.Invoke(null, null);
            client.CreateInterstitialAd(adUnitId);

            Utils.CheckInitialization();
            this.client.OnAdLoaded += (sender, args) =>
            {
                if (this.OnAdLoaded != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLoaded(this, args));
                }
            };

            this.client.OnAdFailedToLoad += (sender, args) =>
            {
                if (this.OnAdFailedToLoad != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args));
                }
            };

            this.client.OnAdOpening += (sender, args) =>
            {
                if (this.OnAdOpening != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdOpening(this, args));
                }
            };

            this.client.OnAdClosed += (sender, args) =>
            {
                if (this.OnAdClosed != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdClosed(this, args));
                }
            };

            this.client.OnAdLeavingApplication += (sender, args) =>
            {
                if (this.OnAdLeavingApplication != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLeavingApplication(this, args));
                }
            };
        }
예제 #4
0
        private void ConfigureBannerEvents()
        {
            this.client.OnAdLoaded += (sender, args) =>
            {
                if (this.OnAdLoaded != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLoaded(this, args));
                }
            };

            this.client.OnAdFailedToLoad += (sender, args) =>
            {
                if (this.OnAdFailedToLoad != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args));
                }
            };

            this.client.OnAdOpening += (sender, args) =>
            {
                if (this.OnAdOpening != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdOpening(this, args));
                }
            };

            this.client.OnAdClosed += (sender, args) =>
            {
                if (this.OnAdClosed != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdClosed(this, args));
                }
            };

            this.client.OnAdLeavingApplication += (sender, args) =>
            {
                if (this.OnAdLeavingApplication != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLeavingApplication(this, args));
                }
            };
        }
예제 #5
0
        private AdLoader(Builder builder)
        {
            this.AdUnitId = string.Copy(builder.AdUnitId);
            this.CustomNativeTemplateClickHandlers =
                new Dictionary <string, Action <CustomNativeTemplateAd, string> >(
                    builder.CustomNativeTemplateClickHandlers);
            this.TemplateIds = new HashSet <string>(builder.TemplateIds);
            this.AdTypes     = new HashSet <NativeAdType>(builder.AdTypes);

            Type googleMobileAdsClientFactory = Type.GetType(
                "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp");
            MethodInfo method = googleMobileAdsClientFactory.GetMethod(
                "BuildAdLoaderClient",
                BindingFlags.Static | BindingFlags.Public);

            this.adLoaderClient = (IAdLoaderClient)method.Invoke(null, new object[] { this });

            Utils.CheckInitialization();

            this.adLoaderClient.OnCustomNativeTemplateAdLoaded +=
                delegate(object sender, CustomNativeEventArgs args)
            {
                if (this.OnCustomNativeTemplateAdLoaded != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnCustomNativeTemplateAdLoaded(this, args));
                }
            };
            this.adLoaderClient.OnAdFailedToLoad += delegate(
                object sender, AdFailedToLoadEventArgs args)
            {
                if (this.OnAdFailedToLoad != null)
                {
                    MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args));
                }
            };
        }