Using the Google AdMob Xamarin Component in a MonoGame project

I want to integrate AdMob in my game and found this Xamarin Component:

The sample code looks nice and clean, but it is UIView-based, while my game is based on the Game State Management structure (e.g. ScreenManager, GameScreen, etc.). For example, I cannot create an adView using the code below:

adView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (0, 0)) {
    AdUnitID = AdmobID,
    RootViewController = this
};

Neither can I add the adView with this snippet from the sample:

adView.DidReceiveAd += (sender, args) => {
    if (!viewOnScreen) View.AddSubview (adView);
    viewOnScreen = true;
};

Is there a way to get around this problem? =(

Grab an instance of the RootViewController using:

UIViewController rvc = UIApplication.SharedApplication.Windows[0].RootViewController;

You can then add your GADBannerView to the RootViewController view:

rvc.View.AddSubview(adView)

Hope this helps,
Ronny.

Thanks so much Ronny! It worked!! =D

No problem, I remember thinking the same thing when I looked at the sample code.