Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Is it possible to add a banner advertising to my xamarin.forms app?

I could not find a solution for banner implementation. The api from admob does not work for windows phone or uwp. Also i can not add a banner via admob or anything with the pcl project. The banner will be shown always at the bottom of the app. I would like to develop the ui in xaml in the pcl project. I found a discussion with a custom renderer. But it was not a banner advertising. Is it possible to add a advertising in a xamarin.forms app for all plattforms or at least for android and apple?


  • kamaeleonkamaeleon DEMember

    THX very much! I will try the posted code. I hope it works for apple. ;)

  • kamaeleonkamaeleon DEMember

    Sorry, i have tested the referenced steps for android but it does not work. I had problems with the nuget versioning for the xamarin components.

    I use currently Xamarin.GooglePlayServices.Ads and Xamarin.Forms Another combination does not work with the ads component.

    I added the admobview to the pcl project, added it to the pcl xaml file, updated the manifest in the android project, set the project settings up to 1G, added the admobrenderer in the android project, the build works and the emulator starts, deploy starts and than the error -> Xamarin.Forms.Xaml.XamlParseException: Position 58:2. Type AdMobView not found in xmlns

    I don´t know why it does not work. :/

  • batmacibatmaci DEMember ✭✭✭✭✭

    @kamaeleon did you find a good solution for it? especially for uwp?

  • kamaeleonkamaeleon DEMember

    @batmaci No, sorry! This is not good for Xamarin.Forms. This is not funny. Many problems with nuget dll compatibility first and at the end, it doesn´t exists a working solution for advertising and xamarin.forms and crossplattform development. :(

  • batmacibatmaci DEMember ✭✭✭✭✭
    You are talking about Windows uwp or general? Because admob works fine on Android for me. Did you have problem also on Android using renderers
  • kamaeleonkamaeleon DEMember

    Nuget compatability -> general :s

    Yes, i have problems with using renderers. I work with Xaml.
    Wich libraries and wich version for admob are you using?

  • batmacibatmaci DEMember ✭✭✭✭✭

    I am also using xaml. I didnt implementing it. I have the latest stable version of XF ad 29.0.02 google services

  • kamaeleonkamaeleon DEMember

    OK... I have a running advertising in my android app. :)
    I reinstalled my complete windows system and installed all visual studio and xamarin components new. :/

    But I don´t know what´s wrong with my iOS app. The advertising was not shown. I get no errors and if I debug the custom renderer everything was OK. I use this code:

    [assembly: ExportRenderer(typeof(AdMobView), typeof(AdMobRenderer))]
    namespace myApp.iOS
    public class AdMobRenderer : ViewRenderer
    const string AdmobID = "myIOSKey";
    BannerView adView;
    bool viewOnScreen;

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
      if (e.NewElement == null)
      if (e.OldElement == null)
        adView = new BannerView(AdSizeCons.SmartBannerPortrait)
          AdUnitID = AdmobID,
          RootViewController = UIApplication.SharedApplication.Windows[0].RootViewController
        adView.AdReceived += (sender, args) =>
          if (!viewOnScreen) this.AddSubview(adView);
          viewOnScreen = true;


  • kamaeleonkamaeleon DEMember

    I found a working sample solution for Android and iOS.

    Now I´m searching for a solution with WindowsPhone or UWP ;)

  • Richy_GeorgeRichy_George INMember ✭✭✭


    I follow that sample ; in android I'm getting the ads but not in iOS, do i miss something ?

  • Liêm_NguyễnLiêm_Nguyễn USMember ✭✭✭✭
  • ionixjuniorionixjunior USMember ✭✭✭
    edited August 2017

    @NguyenLiem RewardedAds is a kind of AdMob?

    @kamaeleon you found some implementation for UWP?

  • lightdmlightdm USMember

    @kamaeleon said:
    I found a working sample solution for Android and iOS.

    Now I´m searching for a solution with WindowsPhone or UWP ;)

    work for xamarin native or xamarin forms ?

  • Liêm_NguyễnLiêm_Nguyễn USMember ✭✭✭✭

    Try this YouTube

    It's using Microsoft Advertising SDK and Google AdMob

  • LearnEverythingLearnEverything USMember ✭✭✭

    On Android Side.


    <activity android:name=""
                android:theme="@android:style/Theme.Translucent" />
        <meta-data android:name="" 
                   android:value="@integer/google_play_services_version" />

    Code C#

    var adView = new AdView(this);
                adView.AdSize = AdSize.SmartBanner;
    #if DEBUG
                //Test Ad
                adView.AdUnitId = "ca-app-pub-3940256099942544/6300978111";
                 adView.AdUnitId = "ca-app-pub-9046876543518976/1606225012";
                var paramss = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                adView.LayoutParameters = paramss;          
                var layout = FindViewById<RelativeLayout>(Resource.Id.mainRootLayout);
                var adRequest = new AdRequest.Builder().Build();
Sign In or Register to comment.