void Start()
    {
        // Create a 250x250 banner.
        AdSize adSize = new AdSize(250, 250);
        bannerView = new BannerView(
                "ca-app-pub-8082064498416450/8145076128", adSize, AdPosition.Bottom);

        // Register for ad events.
        bannerView.AdLoaded += HandleAdLoaded;
        bannerView.AdFailedToLoad += HandleAdFailedToLoad;
        bannerView.AdOpened += HandleAdOpened;
        bannerView.AdClosing += HandleAdClosing;
        bannerView.AdClosed += HandleAdClosed;
        bannerView.AdLeftApplication += HandleAdLeftApplication;

        // Request
        AdRequest request = new AdRequest.Builder()
        .AddTestDevice(AdRequest.TestDeviceSimulator)       // Simulator.
        .AddTestDevice("3BD361B306BE5D37")  // My test device.
        .Build();

        // Load the banner
        bannerView.LoadAd(request);

        // Request the interstitial
        RequestInterstitial();
    }
        // Creates a BannerView and adds it to the view hierarchy.
        public BannerView(string adUnitId, AdSize adSize, AdPosition position)
        {
            client = GoogleMobileAdsClientFactory.BuildBannerClient();
            client.CreateBannerView(adUnitId, adSize, position);

            client.OnAdLoaded += delegate(object sender, EventArgs args)
            {
                OnAdLoaded(this, args);
            };

            client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args)
            {
                OnAdFailedToLoad(this, args);
            };

            client.OnAdOpening += delegate(object sender, EventArgs args)
            {
                OnAdOpening(this, args);
            };

            client.OnAdClosed += delegate(object sender, EventArgs args)
            {
                OnAdClosed(this, args);
            };

            client.OnAdLeavingApplication += delegate(object sender, EventArgs args)
            {
                OnAdLeavingApplication(this, args);
            };
        }
Beispiel #3
0
    void Awake()
    {
        // Banner
        string adUnitId = "ca-app-pub-8299109678258685/4687466858";

        AdSize adSize = new AdSize(250, 50);
        bannerView = new BannerView(adUnitId, adSize, AdPosition.Bottom);
        //bannerView.LoadAd(new AdRequest.Builder().AddTestDevice(deviceId).Build());
        bannerView.LoadAd(new AdRequest.Builder().Build());
        bannerView.Show();
    }
Beispiel #4
0
 public static AndroidJavaObject GetAdSizeJavaObject(AdSize adSize)
 {
     if (adSize.IsSmartBanner)
     {
         return new AndroidJavaClass(AdSizeClassName)
                 .GetStatic<AndroidJavaObject>("SMART_BANNER");
     }
     else
     {
         return new AndroidJavaObject(AdSizeClassName, adSize.Width, adSize.Height);
     }
 }
        // Creates a native express ad view.
        public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
        {
            nativeExpressAdClientPtr = (IntPtr)GCHandle.Alloc(this);
            this.NativeExpressAdViewPtr = Externs.GADUCreateNativeExpressAdView(
                nativeExpressAdClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position);

            Externs.GADUSetNativeExpressAdCallbacks(
                    this.NativeExpressAdViewPtr,
                    this.NativeExpressAdViewDidReceiveAdCallback,
                    this.NativeExpressAdViewDidFailToReceiveAdWithErrorCallback,
                    this.NativeExpressAdViewWillPresentScreenCallback,
                    this.NativeExpressAdViewDidDismissScreenCallback,
                    this.NativeExpressAdViewWillLeaveApplicationCallback);
        }
    private void RequestBanner()
    {
        #if UNITY_ANDROID
        string adUnitId = "ca-app-pub-3940256099942544/6300978111";
        #elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-3940256099942544/6300978111";
        #else
        string adUnitId = "unexpected_platform";
        #endif

        // Custom banner size
        AdSize adSize = new AdSize(bannerWidth, bannerHeight);
        // Create a wxh banner at the bottom left of the screen.
        BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.BottomLeft);
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the banner with the request.
        bannerView.LoadAd(request);
    }
        // Creates a banner view.
        public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position) {
            IntPtr bannerClientPtr = (IntPtr) GCHandle.Alloc(this);

            if (adSize.IsSmartBanner) {
                BannerViewPtr = Externs.GADUCreateSmartBannerView(
                        bannerClientPtr, adUnitId, (int)position);
            }
            else
            {
                BannerViewPtr = Externs.GADUCreateBannerView(
                        bannerClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position);
            }
            Externs.GADUSetBannerCallbacks(
                    BannerViewPtr,
                    AdViewDidReceiveAdCallback,
                    AdViewDidFailToReceiveAdWithErrorCallback,
                    AdViewWillPresentScreenCallback,                    
                    AdViewDidDismissScreenCallback,
                    AdViewWillLeaveApplicationCallback);
        }
Beispiel #8
0
 // Create a BannerView and add it into the view hierarchy.
 public BannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     client = GoogleMobileAdsClientFactory.GetGoogleMobileAdsBannerClient(this);
     client.CreateBannerView(adUnitId, adSize, position);
 }
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name);
 }
 public void SetAdSize(AdSize adSize)
 {
     Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name);
 }
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     Debug.Log("Dummy CreateBannerView");
 }
	private GoogleMobileAds.Api.AdSize getAdSize(){
		AdSize result = null;
		if(customSize){
			result = new AdSize(customWidth, customHeight);
		}else{
			switch(adSize){
			case Sizes.Banner:
				result = AdSize.Banner;
				break;
			case Sizes.IABBanner:
				result = AdSize.IABBanner;
				break;
			case Sizes.Leaderboard:
				result = AdSize.Leaderboard;
				break;
			case Sizes.MediumRectangle:
				result = AdSize.MediumRectangle;
				break;
			case Sizes.SmartBanner:
				result = AdSize.SmartBanner;
				break;
			}
		}
		return result;
	}	
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
 }
Beispiel #14
0
 // Token: 0x06000246 RID: 582 RVA: 0x0000D7EB File Offset: 0x0000BBEB
 public BannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     this.client = GoogleMobileAdsClientFactory.BuildBannerClient();
     this.client.CreateBannerView(adUnitId, adSize, position);
     this.configureBannerEvents();
 }
 // Creates a banner view.
 public void CreateBannerView(String adUnitId, AdSize adSize, AdPosition position) {
     bannerView.Call("create",
             new object[3] { adUnitId, Utils.GetAdSizeJavaObject(adSize), (int)position });
 }
 // Set the ad size for the native express ad view.
 public void SetAdSize(AdSize adSize)
 {
     this.nativeExpressAdView.Call("setAdSize", Utils.GetAdSizeJavaObject(adSize));
 }
 // Creates a native express ad view.
 public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
 {
     this.nativeExpressAdView.Call(
             "create",
             new object[3] { adUnitId, Utils.GetAdSizeJavaObject(adSize), (int)position });
 }
 // Create a BannerView and add it into the view hierarchy.
 public BannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     client = GoogleMobileAdsClientFactory.GetGoogleMobileAdsBannerClient(this);
     client.CreateBannerView(adUnitId, adSize, position);
 }
	public static void ShowBanner(AdSize adSize, AdPosition adPosition)
	{
		Debug.Log("Show Banner Ad");
		#if ADMOB_IMPLEMENTED
		//if we already created it we could just show it
		if(bannerView != null)
			bannerView.Show();
		else//create a new one
		{
			_adSize = adSize;
			_adPosition = adPosition;

			CreateBannerRequest();
		}

		#endif
	}
Beispiel #20
0
 // Token: 0x06000247 RID: 583 RVA: 0x0000D812 File Offset: 0x0000BC12
 public BannerView(string adUnitId, AdSize adSize, int x, int y)
 {
     this.client = GoogleMobileAdsClientFactory.BuildBannerClient();
     this.client.CreateBannerView(adUnitId, adSize, x, y);
     this.configureBannerEvents();
 }