Interstitial Ads

Interstitial ads provide full-screen experiences, commonly incorporating rich media to offer a higher level of interactivity than banner ads. Interstitials are typically shown during natural transitions in your application, such as on app launch, after completing a game level, or while your app is downloading content from the internet. Use MPInterstitialAdController and its delegate callbacks to fetch and display interstitial ads in your app.

Prerequisites

  1. Follow the steps in our Get Started guide to create an account on MoPub and integrate the SDK into your project.

  2. Create an ad unit in the Publisher UI. You will need that ad unit’s ID.

Load Interstitial Ads in Your App

After that, loading interstitial ads is a two-step process:

  1. Pre-fetch the interstitial ad
  2. Display the interstitial ad

Important: Please do not use publisher-provided overlays (such as close buttons) that are located with the ad placement and that subsequently cover the ad creative. Doing so is against MoPub Policy. If you have questions, please reach out to your account team or support@mopub.com for additional assistance.

Step 1. Pre-Fetch the Interstitial Ad

  1. In your view controller’s header file:

    • Import the MPInterstitialAdController.h header file and declare an MPInterstitialAdController *interstitial property.

    • Declare that your view controller implements the MPInterstitialAdControllerDelegate protocol.

     // MyViewController.h
            
     #import "MPInterstitialAdController.h"
        
     @interface MyViewController : UIViewController <MPInterstitialAdControllerDelegate>
            
     @property (nonatomic, retain) MPInterstitialAdController *interstitial;
            
     @end
    
  2. In your view controller’s implementation file, instantiate an MPInterstitialAdController using the class convenience method +interstitialAdControllerForAdUnitId:, passing in your ad unit ID.

  3. Register your view controller as the interstitial’s delegate (for example, self.interstitial.delegate = self;).

  4. Pre-fetch the interstitial ad by calling -loadAd on the interstitial.

Step 2. Display the Interstitial Ad

  1. To display the ad, check the ad’s ready property.

  2. If the ad is ready to be shown, call -showFromViewController: on the interstitial, passing in your view controller.

Sample Code

The following code snippet demonstrates the above steps in the context of a game application; specifically, how to pre-fetch an interstitial and display it after a level has ended.

Important: If you are using MRC, set the -fobjc-arc compiler flag on these files. Follow the instructions in our integration article.

// MyViewController.m

#import "MyViewController.h"

@implementation MyViewController

// Our loadView implementation will pre-fetch our interstitial ad.
- (void)loadView {
    // ... your other -loadView code ...
    [self loadInterstitial];
}

- (void)loadInterstitial {
    // Instantiate the interstitial using the class convenience method.
    self.interstitial = [MPInterstitialAdController
        interstitialAdControllerForAdUnitId:@"<YOUR_ADUNIT_ID_HERE>"];

    // Fetch the interstitial ad.
    [self.interstitial loadAd];
}

// Present the ad only after it is ready.
- (void)levelDidEnd {
    if (self.interstitial.ready) [self.interstitial showFromViewController:self];
    else {
        // The interstitial wasn't ready, so continue as usual.
    }
}

Optional Callbacks

MPInterstitialAdControllerDelegate includes a variety of optional callbacks that you can use to be notified of events, such as when an interstitial has successfully loaded, or when an interstitial is about to appear. Refer to the MPInterstitialAdControllerDelegate in MPInterstitialAdController.h for a list of these methods.

  • Example 1 (pre-fetching): You can be notified that an interstitial was fetched successfully by implementing -interstitialDidLoadAd:.

  • Example 2 (presentation/dismissal callbacks): Suppose that your application is a game. You want to pause the game whenever you present an interstitial, and resume it when the interstitial is dismissed. You can accomplish this using the optional -interstitialWillAppear: and -interstitialDidDisappear delegate callbacks:

      - (void)interstitialWillAppear:(MPInterstitialAdController *)interstitial {
          [self pauseGame];
      }
            
      - (void)interstitialDidDisappear:(MPInterstitialAdController *)interstitial {
          [self resumeGame];
      }
      /**
       Called when an impression is fired on the @c MPMoPubAd instance. Includes information about the impression if applicable.
        
       @param ad The @c MPMoPubAd instance that fired the impression
       @param impressionData Information about the impression, or @c nil if the server didn't return any information.
       */
      - (void)mopubAd:(id<MPMoPubAd>)ad didTrackImpressionWithImpressionData:(MPImpressionData * _Nullable)impressionData;
    

Known Issue with WKWebView

Due to a known issue with WKWebView not respecting the ringer or mute switch settings to control volume, certain creatives may have audio on even when the device is on mute and the volume is non-zero.

Last updated September 23, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)