Google Mobile Ads iOS unable to load SearchRequest


I want to integrate Google Ads in my app but im stuck when it's time to load the request and get the Ad.
I'm trying to load a SearRequest for displaying a SearchBannerView but not methods seems to match my needs, the LoadRequest methods of the SearchBannerView doesn't accept SearchRequest only Request and no cast exists between those two classes.

However the google docs says it's possible :

Here is my code :

this.banner = new SearchBannerView(AdSizeCons.Banner, new CGPoint(0, 0));
this.banner.TranslatesAutoresizingMaskIntoConstraints = false;
this.banner.AdSize = AdSizeCons.Banner;
this.banner.AdUnitID = this.AdService.AdMobUnitId;
this.banner.AdReceived += this.AdReceived;
this.banner.RootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;

var request = new SearchRequest();
request.Query = ((GoogleAdViewModel)this.DataContext).Query;

// my request isn't accepted

Anyone has succeed to make SearBannerView load something using the Google Ads component of Xamarin ?

FYI it's for an iOS app and i'm using this component :


  • StephaneCordonnierStephaneCordonnier FRMember ✭✭

    This is an issue in the binding library.

    When you look the native SDK, classes are declared like this :

    @interface GADRequest : NSObject<NSCopying>
    @interface GADSearchRequest : GADRequest

    But when you look the binding library, you can see this :

    [BaseType(typeof(NSObject), Name="GADRequest")]
    interface Request : INSCopying
    [BaseType(typeof(NSObject), Name="GADSearchRequest")]
    interface SearchRequest

    As you can see, there's a difference in the binding library because the base type of SearchRequest is not Request but NSObject.

    I've downloaded the source code of the binding library, changed the lines as you can see below, recompiled the library and it's working :smiley:

    [BaseType(typeof(NSObject), Name="GADRequest")]
    interface Request : INSCopying
    [BaseType(typeof(Request), Name="GADSearchRequest")]
    interface SearchRequest
  • IsraelSotoIsraelSoto MXXamarin Team Xamurai
    edited May 2016

    @EtiennePommier.Dcube @StephaneCordonnier

    Hi guys, thanks for letting know this. I'll continue this thread on GoogleApisForiOSComponents repo:

    Etienne, a big apology for taking some time to give a reply.

    Thanks for helping us to make better components!

    Israel Soto.

  • Thanks for the answer @StephaneCordonnier it's working perfectly.

    @IsraelSoto, i hope this fix will be integrated soon :smile:

  • Still no release with the fix included. Does also have this bug?

Sign In or Register to comment.