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.