Ejemplo n.º 1
0
		public Advertisement() {
	// code for admob "using AlexTouch.GoogleAdMobAds"
	UIViewController vc = new UIViewController ();
	UIViewController controller = UIApplication.SharedApplication.Windows [0].RootViewController;

	var ad = new GADBannerView (GADAdSizeCons.SmartBannerLandscape, new PointF (0, 0))
	{
			AdUnitID = "ca-app-pub-8135914038151970/6935695643",
		RootViewController = vc
	};
	ad.Hidden = false;

	ad.DidReceiveAd += delegate {
		ad.Hidden = false;
		ad.Frame = new System.Drawing.RectangleF (0, (int) 0, (int) (ad.Bounds.Width), (int) (ad.Bounds.Height));
		Console.WriteLine ("AD Received");
	};

	ad.DidFailToReceiveAdWithError += delegate(object sender, GADBannerViewDidFailWithErrorEventArgs e) {
		ad.Hidden = true;
		Console.WriteLine (e.Error);

	};

	ad.WillPresentScreen += delegate {
		Console.WriteLine ("showing new screen");
	};

	ad.WillLeaveApplication += delegate {
		Console.WriteLine ("I will leave application");
	};

	ad.WillDismissScreen += delegate {
		Console.WriteLine ("Dismissing opened screen");
	};
	ad.UserInteractionEnabled = true;

	vc.View.AddSubview(ad);
	vc.View.Frame = new System.Drawing.RectangleF(0f,  0f,  (int)(ad.Bounds.Width), (int)(ad.Bounds.Height));
	controller.View.AddSubview(vc.View);

	Task.Factory.StartNew(() => {
		while (true)
		{
			Console.WriteLine("Requesting Ad");
			UIApplication.SharedApplication.InvokeOnMainThread (delegate { 
				GADRequest r = new GADRequest();

				ad.LoadRequest(r);
			});
			System.Threading.Thread.Sleep(30000);
		}
	});
	}
		public virtual void AdViewDidReceiveAppEvent (GADBannerView banner, string name, string info)
		{
			throw new You_Should_Not_Call_base_In_This_Method ();
		}
		public virtual void WillDismissScreen (GADBannerView adView)
		{
			throw new You_Should_Not_Call_base_In_This_Method ();
		}
		public virtual void DidFailToReceiveAdWithError (GADBannerView view, GADRequestError error)
		{
			throw new You_Should_Not_Call_base_In_This_Method ();
		}
		public virtual void DidReceiveAd (GADBannerView view)
		{
			throw new You_Should_Not_Call_base_In_This_Method ();
		}
		public virtual void WillLeaveApplication (GADBannerView adView)
		{
			throw new You_Should_Not_Call_base_In_This_Method ();
		}
		public virtual void WillChangeAdSizeTo (GADBannerView view, GADAdSize size)
		{
			throw new You_Should_Not_Call_base_In_This_Method ();
		}