i would like to try to test bannerViewActionDidFinish:
after a click-through is complete.
my experience is that when testing with the fake ads in a debug-build or on the simulator. has anyone been able to successfully test this?
bannerViewActionShouldBegin:willLeaveApplication:
is always called with willLeave == NO
, and when one clicks on the test iAd, the confirmation appears telling me that iAd is set up correctly … but after closing that window, bannerViewActionDidFinish:
is never called.
further info: the iAd banners all show up and disappear correctly in testing, and they are in the app store distribution build and function just fine … up to the point that the user comes back from a click-through operation. i want to use bannerViewActionDidFinish:
for this, but i can't see a way to test it with fake ads.
here's the pertinent code (hopefully anyone helping does not need to see the layout code; it appears to always do the right thing in terms of presenting or hiding the iAd banner based on whether the ad is loaded in the banner or not, or whether a generated error occurs or not, and also matches the corresponding log output; the only thing that isn't happening is that bannerViewActionDidFinish:
is never called during testing:
#pragma mark - ADBannerViewDelegate implementation
#pragma mark @optional
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3
// This method is invoked when the banner has confirmation that an ad will be presented, but
// before the ad has loaded resources necessary for presentation.
- (void)bannerViewWillLoadAd:(ADBannerView *)banner {
if (banner == self.adBannerView)
#if DEBUG
NSLog(@"(%@)bannerViewWillLoadAd", self.navigationItem.title),
#endif
banner.hidden = NO;
#if DEBUG
else
NSLog(@"== banner that will load ad is different than this view's banner ==");
#endif
}
#endif
// This method is invoked each time a banner loads a new advertisement. Once a banner has
// loaded an ad, it will display that ad until another ad is available. The delegate might
// implement this method if it wished to defer placing the banner in a view hierarchy until the
// banner has content to display.
- (void)bannerViewDidLoadAd:(ADBannerView*)banner {
#if DEBUG
NSLog(@"(%@)bannerViewDidLoadAd: bannerLoaded==%d",
self.navigationItem.title, banner.isBannerLoaded ? 1 : 0);
#endif
if (self.view.window)
[UIView animateWithDuration:0.3 animations:^{
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}];
#if DEBUG
else
NSLog(@"(%@)bannerViewDidLoadAd: window not visible, skipping …",
self.navigationItem.title);
#endif
}
// This method will be invoked when an error has occurred attempting to get advertisement content.
// The ADError enum lists the possible error codes.
- (void)bannerView:(ADBannerView*)banner didFailToReceiveAdWithError:(NSError *)error {
#if DEBUG
NSLog(@"(%@)%@: bannerLoaded==%d",
self.navigationItem.title, error, banner.isBannerLoaded ? 1 : 0);
#endif
if (self.view.window)
{
banner.hidden = !banner.isBannerLoaded; // can't say NO, in case banner loaded w/error!
[UIView animateWithDuration:0.3 animations:^{
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}];
}
#if DEBUG
else
NSLog(@"(%@)%s window not visible, skipping…",
self.navigationItem.title, __FUNCTION__);
#endif
}
// This message will be sent when the user taps on the banner and some action is to be taken.
// Actions either display full screen content in a modal session or take the user to a different
// application. The delegate may return NO to block the action from taking place, but this
// should be avoided if possible because most advertisements pay significantly more when
// the action takes place and, over the longer term, repeatedly blocking actions will
// decrease the ad inventory available to the application. Applications may wish to pause video,
// audio, or other animated content while the advertisement's action executes.
- (BOOL)bannerViewActionShouldBegin:(ADBannerView*)banner willLeaveApplication:(BOOL)willLeave {
return YES;
}
// This message is sent when a modal action has completed and control is returned to the
// application. Games, media playback, and other activities that were paused in response to the
// beginning of the action should resume at this point.
- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
// all new code, to be tested
[self configureView];
[UIView animateWithDuration:0.3 animations:^{
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}];
}