Integrate Admob into an iOS app that uses monogame

I have been trying to do this for several days and cannot do this. And I tried to find some samples, but they are all on Android. Has anyone succeeded in integrating admob on iOS?

+4
source share
2 answers

I am having problems with AdMob bindings from the monotouch-bindings repository. But then I switched to AlexTouch.GoogleAdMobAds bindings and they work great. You can find a sample using AlexTouch.GoogleAdMobAds in README on Github. It's quite simple, but if you need help, feel free to ask a more detailed question.

+2
source
// 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 = "ADMOB_ID", 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"); InvokeOnMainThread (delegate { GADRequest r = new GADRequest(); ad.LoadRequest(r); }); System.Threading.Thread.Sleep(30000); } }); 
0
source

All Articles