So Ive been trying to integrate iAd into my app. I managed to get banners working just fine but I have been having a lot of trouble with the fullscreen ads. I have been following this tutorial as it seems to be the best and most informative one that I found and the apple docs don't really off much support.
For those wanting to know, I am trying to achieve an effect where when the user gets a game over a fullscreen ad is displayed. bearing in mind the app is also horizontal and I would also like a way to exit the ad as I believe that the iAds don't come with an exit button, or something similar.
The problem is that the ad isn't displayed, I'm not getting any errors it just doesnt seem to get shown on screen
Apologize if the explanation is short or lacks information, ask away if you need anything else from me :)
-Ryan
EDIT: to those who can't access the hyperlink or simply want to see the code I'm using, here it is:
@implementation GameViewController {
UIView *_adView;
ADInterstitialAd* _interstitial;
BOOL _requestingAd;
}
.
-(void)showFullScreenAd {
if (_requestingAd == NO) {
_interstitial = [[ADInterstitialAd alloc] init];
_interstitial.delegate = self;
NSLog(@"Ad Request");
_requestingAd = YES;
}
}
-(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error {
_requestingAd = NO;
NSLog(@"Ad didFailWithERROR");
NSLog(@"%@", error);
}
-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
NSLog(@"Ad DidLOAD");
if (interstitialAd.loaded) {
CGRect interstitialFrame = self.view.bounds;
interstitialFrame.origin = CGPointMake(0, 0);
_adView = [[UIView alloc] initWithFrame:interstitialFrame];
[self.view addSubview:_adView];
[_interstitial presentInView:_adView];
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(closeAd:) forControlEvents:UIControlEventTouchDown];
button.backgroundColor = [UIColor clearColor];
[button setBackgroundImage:[UIImage imageNamed:@"close-button.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 30, 30);
[_adView addSubview:button];
[UIView beginAnimations:@"animateAdBannerOn" context:nil];
[UIView setAnimationDuration:1];
[_adView setAlpha:1];
[UIView commitAnimations];
}
}
-(void)closeAd:(id)sender {
[UIView beginAnimations:@"animateAdBannerOff" context:nil];
[UIView setAnimationDuration:1];
[_adView setAlpha:0];
[UIView commitAnimations];
_adView=nil;
_requestingAd = NO;
}
-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
_requestingAd = NO;
NSLog(@"Ad DidUNLOAD");
}
-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
_requestingAd = NO;
NSLog(@"Ad DidFINISH");
}
Eh, that tutorial is just a copy of my answer here and is extremely dated.
I have a newer implementation here. It's still not perfect though.
Personally, I'd suggest using AdMob or Facebook for your interstitial advertisements. iAd's interstitials are poorly executed.