Use Your Loaf

[[brain engage] write]

Ad Inventory Unavailable With iOS 4.2

I have had some real issues testing the iAd framework since Apple released iOS 4.2 (and the 4.2.1 update). I mentioned yesterday the changes required to also support the iPad. However, when testing either in the simulator or on a device running 4.2.x the test iAd is never displayed. I have not managed to resolve this issue yet but since I guess lots of people are suffering this same problem I thought I would share the pain…

ADBannerViewDelegate Methods

The ADBannerViewDelegate protocol has two methods that are called to allow the iAd framework to inform the application when an advertisement is loaded or when an error occurs. When everything is working the bannerViewDidLoadAd: method is called to inform the application that it can show the banner view.

When running a developer build of an application what should happen is that a test iAd is eventually returned. I say eventually because Apple do say that they will sometimes simulate a failure to retrieve an Ad to allow the developer to properly test both success and failure cases. However within a few minutes you should get a test iAd.

If the iAd framework encounters an error when attempting to retrieve an Ad it calls the bannerView:didFailToReceiveAdWithError: method. This method includes an NSError object that can be used to determine the reason for the failure. The easiest way to do this is to add an NSLog call to log the error description to the console:

- (void)bannerView:(ADBannerView *)banner 
        didFailToReceiveAdWithError:(NSError *)error {
  NSLog(@"bannerView:didFailToReceiveAdWithError: %@",
        [error localizedDescription]);
  [self hideBanner];
}

Ad Inventory Unavailable error messages

Running the application on the simulator with iOS 4.2 writes the following message to the Xcode console:

bannerView:didFailToReceiveAdWithError: The operation couldn't be
completed. Ad inventory unavailable

A similar result occurs when running on a device (in this case a fourth generation iPod Touch) running iOS 4.2.1. Also what is interesting is that when running on a device that is still at iOS 4.1 the problem does not exist – the test iAd is immediately displayed. Deploying to the simulator running iOS 4.1 also results in a test iAd being displayed so it does seem to be a problem related to iOS 4.2.

What is frustrating is that I have once or twice managed to get a test iAd to appear on the device running iOS 4.2 but not in a repeatable way. Looking through the Apple developer forums would seem to indicate that many people are experiencing this issue and as yet nobody has figured out the root cause. Also what is not clear is if this issue is only with test Ads or also impacts production Ads.

Apple is in the process of rolling out iAd’s to a number of additional countries so you may be tempted to think that this problem is related to that and will eventually fix itself. However I doubt the rollout of the production service should have any impact on the test iAds. If you are experiencing this issue my only suggestion right now is to file a bug report with Apple and hope they figure it out soon. If I find a solution I will of course update this post….

Comments