Interstitial Ads

Interstitial ads are full-screen ads that are overlaid on top of an app. They are generally displayed at natural app transition points such as in between game levels.

This guide explains how to integrate interstitial ads into your Google Mobile Ads iOS app.

The ad unit and samples that we provide return test ads. Test ads are always available, even if your account is suspended or disabled. For more information, review the AdMob policies and learn more about invalid activity.

It is against AdMob policy to click on your own live ads. During development and testing, use only test ads. If you do need to render live ads before launch, avoid clicking on them. If you click on live ads, your AdMob account may be suspended.

Prerequisites

Complete the Add the Firebase and Mobile Ads SDKs section of the Get Started guide.

Helpful primers

  • You can download the interstitial example from GitHub and follow along by adding interstitial ads to your project.

    Objective-C Swift

  • You may also want to read the Ad Events guide to take full advantage of interstitial ads. Some examples in this guide use ad events to perform more advanced interstitial integrations.

Add interstitial ads to your project

The recommended lifecycle for a GADInterstitial is to preload it when the app starts and show it at an appropriate time in your app when it's ready. This snippet shows how to create a GADInterstitial property, initialize it, and load it with an ad:

Objective-C

@import GoogleMobileAds;

@interface ViewController () <UIAlertViewDelegate>

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  [self startNewGame];
}

- (void)startNewGame {
  [self createAndLoadInterstitial];

  // Set up a new game.
}

 - (void)createAndLoadInterstitial {
  self.interstitial =
      [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];

  GADRequest *request = [GADRequest request];
  // Request test ads on devices you specify. Your test device ID is printed to the console when
  // an ad request is made.
  request.testDevices = @[ kGADSimulatorID, @"2077ef9a63d2b398840261c8221a0c9b" ];
  [self.interstitial loadRequest:request];
}

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, UIAlertViewDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()

    startNewGame()
  }

  fileprivate func startNewGame() {
    createAndLoadInterstitial()

    // Set up a new game.
  }

  fileprivate func createAndLoadInterstitial() {
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
    let request = GADRequest()
    // Request test ads on devices you specify. Your test device ID is printed to the console when
    // an ad request is made.
    request.testDevices = [ kGADSimulatorID, "2077ef9a63d2b398840261c8221a0c9b" ]
    interstitial.load(request)
  }
}

Interstitials should be shown at a natural stopping point. When you are ready to show an interstitial, check if it's ready before attempting to display it. Here's an example of showing the interstitial when a game is over:

Objective-C

- (void)endGame {
  [[[UIAlertView alloc]
          initWithTitle:@"Game Over"
                message:@"Your time ran out!"
               delegate:self
      cancelButtonTitle:@"Ok"
      otherButtonTitles:nil] show];
}

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
  if (self.interstitial.isReady) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
  // Give user the option to start the next game.
}

Swift

fileprivate func endGame() {
  UIAlertView(title: "Game Over",
              message: "Your time ran out!",
              delegate: self,
              cancelButtonTitle: "Ok").show()
}

func alertView(_ alertView: UIAlertView, willDismissWithButtonIndex buttonIndex: Int) {
  if interstitial.isReady {
    interstitial.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
  // Give user the option to start the next game.
}

The app must explicitly call this method at the appropriate time.

The result

Here's what the app looks like when an interstitial is shown:

Only show GADInterstitial once

GADInterstitial is a one time use object. That means once an interstitial is shown, hasBeenUsed returns true and the interstitial can't be used to load another ad. To request another interstitial, you'll need to create a new GADInterstitial object. The best practice, as shown above, is to have a helper method to handle creating and loading an interstitial.

The best place to allocate another interstitial is in the interstitialDidDismissScreen: method on GADInterstitialDelegate so that the next interstitial starts loading as soon as the previous one is dismissed. You may even consider breaking out interstitial initialization into its own helper method:

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [self createAndLoadInterstitial];
}

- (GADInterstitial *)createAndLoadInterstitial {
  GADInterstitial *interstitial =
      [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
  interstitial.delegate = self;
  [interstitial loadRequest:[GADRequest request]];
  return interstitial;
}

- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial {
  self.interstitial = [self createAndLoadInterstitial];
}

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = createAndLoadInterstitial()
}

func createAndLoadInterstitial() -> GADInterstitial {
  var interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
  interstitial.delegate = self
  interstitial.load(GADRequest())
  return interstitial
}

func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  interstitial = createAndLoadInterstitial()
}

By preloading another interstitial immediately after the previous one is dismissed, your app is prepared to show an interstitial again at the next logical break point.

FAQ

How do I optimize the user experience for my interstitial ads?
Refer to the interstitial implementation guidelines.
I'm getting the message "Cannot present interstitial. It is not ready."
This error means the interstitial ad was not successfully fetched. To prevent this warning from happening, use the isReady method to check if the interstitial is ready to present.
I'm getting the error "Request Error: Will not send request because interstitial object has been used."
Interstitials are a one-time-use object. You must create a new interstitial object to make another interstitial ad request.
I'm getting the error response "Request Error: No ads to show." and am not getting any ads back.

When creating an ad unit, make sure to specify Interstitial for the ad type. Interstitial ads will not serve to ad units of type Banner.

Send feedback about...

AdMob by Google
AdMob by Google