xamarinxamarin.iosdouble-clickdouble-click-advertising

DoubleClick Native Template Ads using Xamarin iOS


We are trying to load DoubleClick Native Template Ads using the Google.MobileAds for iOS in Xamarin. We load the Native Ad using the following code:

AdLoader adLoader = new AdLoader(adUnitId, this, new NSObject[]{ AdLoaderType.NativeCustomTemplate }, new AdLoaderOptions[] { });
adLoader.Delegate = new MyCustomNativeCustomTemplateAdLoaderDelegate(new string[] { templateId }, holderUI, onAdLoaded, onAdFailed);
adLoader.LoadRequest(Google.MobileAds.DoubleClick.Request.GetDefaultRequest());

In most cases, ads are successfully rendered but sometimes they are not rendered at all without calling to any of the following callbacks (DidFailToReceiveAd, DidReceiveNativeCustomTemplateAd) and there is a blank white space instead of an ad. If we click on the blank space it shows a popup saying :Invalid URI: The URI is empty. When we click the popup's ok button then the ad is successfully rendered. Anyone knows what the problem might be?



Solution

  • To anyone out there who might have the same issue, here's the answer:

    The code above was called every time in UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) method. Now, we put the first 2 lines of code in UITableViewCell constructor and from GetCell we call only the last line.