My app is on the App Store and it doesn't show any ad. So, after contacting Apple and receiving no solution, I saw this error in the console while running my app on the simulator:
[AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=1 "Service session terminated." UserInfo=0x7f18e160 {ADInternalErrorCode=1002, NSLocalizedDescription=Service session terminated.}
Is that the reason why my app doesn't show any ads and just shows a white space where the ADBannerView
is?
Sounds like you haven't included the ADBannerView
's delegate methods. I've commented the parts you may be missing from your code.
#import <iAd/iAd.h>
@interface ViewController () <ADBannerViewDelegate> // Have you included this?
@end
@implementation ViewController {
// Your iAd Banner
ADBannerView *iAdView;
}
-(void)viewDidLoad {
[super viewDidLoad];
// Setup iAd view
iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero];
iAdView.delegate = self; // And have you done this?
[iAdView setFrame:CGRectMake(0, 0, iAdView.bounds.size.width, iAdView.bounds.size.height)];
iAdView.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height - (iAdView.bounds.size.height / 2));
[self.view addSubview:iAdView];
iAdView.alpha = 0.0;
}
// And have you included these delegate methods to handle when an ad is received or not?
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"iAd received ad");
// display ad
iAdView.alpha = 1.0;
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"iAd failed");
// Hide ad
iAdView.alpha = 0.0;
}