7

I have an iAd which shows up fine when connected to the Network. On the iOS simulator or testing on my device, if I open up my app, see the iAd, then go to settings and turn on airplane mode, and return to the app, the banner slide off the screen. Great. Now, if I turn airplane mode back off (network is ON), the iAd doesn't reappear - even after waiting for 10-15 minutes.

So, here are my questions:

  1. Does the iAd Test Advertisement refresh itself the same as a real iAd would (every minute or so)?

  2. Is there a way to force the iAd to refresh and request a new ad when the network is detected?

I just can't find information on the behaviour of the Test Ads anywhere, and I can't test with real Ads until I upload the app to the App Store (right?)

Heres my code:

Where the iAd is created:

- (void)viewDidLoad
{
    adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 410, 320, 50)];
    adView.frame = CGRectOffset(adView.frame, 0, 50);
    adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    [self.view addSubview:adView];
    adView.delegate=self;
    self.bannerIsVisible=NO;
    [super viewDidLoad];
}

And the delegate methods:

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    NSLog(@"AdWin");
    if (!self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, -50);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"AdLose");
    if (self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, 50);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    }
}

The delegate method NSLog calls only appear once - not every minute, like I would expect if the Ad was getting refreshed.

Andrew_L
  • 3,021
  • 2
  • 19
  • 18

1 Answers1

2

1- yes and like live ads there are some times with no ad at all, it can be hours. I believe the refresh cycle is 3 minutes but it seems apple can change it as they will 2- you shouldn't need to, when properly setup this happens automatically. I have an app with ads and it behaves correctly when switching network or using the airplane setting

Now, there seems to be something about the airplane setting, see this thread : iAds Loading Throttled After Re-Launching App From Background (Also Happens In iAdSuite), but I don't have the final answer. Maybe you could explore more by changing your NSLog in didFail... to NSLog(@"%@", error) to check what it exactly says. Ah and indeed there is no way to test with real ads until it's accepted in the appstore.

Community
  • 1
  • 1
gregory
  • 826
  • 1
  • 6
  • 6
  • Thanks for the suggestions. The thing that puzzles me is that is I start the app (using xCode) on my iPhone with an interent connection and I get my log "AdWin" every 60 seconds, as expected. If I start the app the same way, except with Airplane Mode on, I get the "AdLose" in my log exactly once. I would have expected it to fail every 60 seconds. The error it gives is: `Error Domain=ADErrorDomain Code=1 "The operation couldn’t be completed. (ADErrorDomain error 1.)"` – Andrew_L Dec 04 '11 at 03:32
  • I'm stuck as well at that point, the key thing I believe is you receive an ADError where in my tests I receive a NSURL error and apparently the NSURL error is well handled. I would suggest to include a logic like : when the error is and ADErrorxxx kill the banner and start it all over again (ie. release + realloc as in viewDidLoad). – gregory Dec 04 '11 at 16:04
  • I'm going to mark this as the accepted answer, because it was the most helpful. I'm satisfied that mine will work because I downloaded the Apple sample program `iAdSuite`, and found it gave the same error under the same conditions. Thanks – Andrew_L Dec 05 '11 at 01:37