- (void)createAndLoadInterstitial {
self.interstitial =
[[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
self.interstitial.delegate = self;
GADRequest *request = [GADRequest request];
[self.interstitial loadRequest:request];
}
int counter = 0;
#pragma Interstitial button actions
- (IBAction)playAgain:(id)sender {
if (counter % 5 == 0) {
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Interstitial not ready"
message:@"The interstitial didn't finish loading or failed to load"
delegate:self
cancelButtonTitle:@"Drat"
otherButtonTitles:nil] show];
}
}
counter++;
}