1
votes

iAd is working fine on iPhone 3GS having iOS 5.0.1 and iPhone 4 having iOS 4.3.1 But it doesn't work on iPad 2 having iOS 5.0.1.

I am Getting the follwoing error.

Error Domain=ADErrorDomain Code=3 "The operation couldn\u2019t be completed. Ad inventory unavailable" UserInfo=0x118ca00 {ADInternalErrorCode=3, NSLocalizedFailureReason=Ad inventory unavailable}

Below is the Code:-

- (void)createAdView {
    Class cls = NSClassFromString(@"ADBannerView");
    if (cls) {
        adView = [[cls alloc] initWithFrame:CGRectZero];

    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifier320x50,
                                             ADBannerContentSizeIdentifier480x32, nil];

    // Set the current size based on device orientation
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    adView.delegate = self;

    adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;

    // Set intital frame to be offscreen
    CGRect adFrame = adView.frame;
    adFrame.origin.y = -44;
    adView.frame = adFrame;
    [UIView beginAnimations:@"showBanner" context:NULL];
    [self.view addSubview:adView];
    [UIView commitAnimations];
}
}

   //Hides iAd Banner
 - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error  {
if (bannerIsVisible){
    [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    adView.frame = CGRectOffset(adView.frame, 0, -44);  // Move above screen
    [UIView commitAnimations];
    bannerIsVisible = NO;
}
}

   //Shows iAd Banner.
  - (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!bannerIsVisible)   {
    [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
    adView.frame = CGRectOffset(adView.frame, 0, +44);  // Show on top of screen
    [UIView commitAnimations];
    bannerIsVisible = YES;
}   
  }


Any help would be appreciated.

1

1 Answers

0
votes

The answer is in the error message given: Ad inventory unavailable.

It's not a problem in your code, it's that Apple do not have enough ads to serve. Their fill rate is pretty low so you have to cater for the situation where no ad is available. Many people use services such as AdWhirl to fall back to other ad networks or even display "house" ads.