Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Request Error: No ad to show.

135 views
Skip to first unread message

Adam Howitt

unread,
May 16, 2014, 11:49:42 AM5/16/14
to google-adm...@googlegroups.com
I'm having trouble getting my DFP banner to show up. If I uncomment request.testDevices I see the test smart banner.  If I leave it commented it out I continually get the error caught by my didFail delegate method: "Request Error: No ad to show."

Here is my ad slot setup:




Here is my order and line item setup:




and here is the code:



NSString * const kDFPAdUnit320x50 = @"/mynetworkid/myadid"; 
...

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (section== 0) {
        return 60.0;
    } else {
        return 0.0;
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    if (section == 0) {
        if (!bannerView_) {
            bannerView_ = [[DFPBannerView alloc] initWithAdSize:kGADAdSizeBanner];
            
            bannerView_.adUnitID = kDFPAdUnit320x50;
            
            bannerView_.rootViewController = self;
            bannerView_.delegate = self;
            GADRequest *request = [GADRequest request];
            //request.testDevices = @[ @"mydevice" ];
            [bannerView_ loadRequest:request];
        }
        return bannerView_;
    } else {
        return nil;
    }
}
- (void)adViewDidReceiveAd:(DFPBannerView *)bannerView {
    DLog(@"Got banner");
}
- (void)adView:(DFPBannerView *)bannerView
didFailToReceiveAdWithError:(GADRequestError *)error {
    DLog(@"%@",[error description]);
    bannerView_ = nil;
}



Adam Howitt

unread,
May 16, 2014, 11:57:26 AM5/16/14
to google-adm...@googlegroups.com
Weirdly enough the DFP console now shows 9 impressions, none of which have appeared on my device yet.

Adam Howitt

unread,
May 16, 2014, 12:02:44 PM5/16/14
to google-adm...@googlegroups.com
Oh - and I see this in the console on the simulator

<Google> To get test ads on this device, call: request.testDevices = @[ GAD_SIMULATOR_ID ];

and a similar thing when running on the device:

<Google> To get test ads on this device, call: request.testDevices = @[ @"xxxxx" ];

But I'm not trying to get test ads - the line item I created was a house ads line item where impressions and CTR aren't important.  Is there a switch to tell it to serve impressions? Does it matter that I'm running the debug build and not an ad hoc?

On Friday, May 16, 2014 11:49:42 AM UTC-4, Adam Howitt wrote:

Adam Howitt

unread,
May 16, 2014, 3:06:34 PM5/16/14
to google-adm...@googlegroups.com
Okay - think I just figured this out. In my function I was returning the bannerview as the view for my footer (didn't work). I tried creating a view and then adding the DFPBannerView as a subview and all was well at last.  I moved the addSubView to the delegate method for receiving a banner.  Here's my final implementation for anyone trying to do do this (add a banner as a tableView footer:

NSString * const kDFPAdUnit320x50 = @"/networkid/adid";
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (section== 0 && bannerView_ != nil) {
        return 60.0;
    } else {
        return 0.0;
    }
}
-(UIView *)tableView:(UITableView *)tv viewForFooterInSection:(NSInteger)section {
    if (section == 0) {
        if (!footerView) {
            CGRect footerFrame = [tv rectForFooterInSection:0];
            footerView = [[UIView alloc] initWithFrame:footerFrame];
            footerView.backgroundColor = [UIColor whiteColor];
            GADAdSize sz = GADAdSizeFromCGSize(CGSizeMake(320, 50));
            bannerView_ = [[DFPBannerView alloc] initWithAdSize:sz];
            //pad bannerview by five pixels above and below
            CGRect newFrame= bannerView_.frame;
            newFrame.origin.y += 5;
            bannerView_.frame = newFrame;
            
            bannerView_.adUnitID = kDFPAdUnit320x50;
            
            bannerView_.rootViewController = self;
            bannerView_.delegate = self;
            GADRequest *request = [GADRequest request];
            // Initiate a generic request to load it with an ad.
            [bannerView_ loadRequest:request];
        }
        return footerView;
    } else {
        return nil;
    }
}
- (void)adViewDidReceiveAd:(DFPBannerView *)bannerView {
    DLog(@"Got banner");
    [footerView addSubview:bannerView_];
}
- (void)adView:(DFPBannerView *)bannerView
didFailToReceiveAdWithError:(GADRequestError *)error {
    DLog(@"%@",[error description]);
    bannerView_ = nil;
    [self.tableView reloadData];  
}

Eric Leichtenschlag

unread,
May 16, 2014, 7:46:47 PM5/16/14
to google-adm...@googlegroups.com
I'm glad you got it working, although that code change shouldn't have affected whether the ad request was successful. Perhaps you just needed to wait a little longer for your DFP UI changes to propagate to all servers.

As for your code, a couple small best practices I'd suggest are to use the kGADAdSizeBanner constant and pass an origin in when creating the banner:

CGPoint origin = CGPointMake(0, 5);
bannerView_ =[[DFPBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];

Thanks,
Eric
Reply all
Reply to author
Forward
0 new messages