Interstitial Integration
Interstitial ads provide full screen experiences, you can preload an interstitial ad and show it during the normal flow in your app. You can use the InstalInterstitial object and its associated listeners to fetch and display interstitial ads in your app.
Prerequisites:
Before integrating interstitial ads in your app, you’ll need to go through the steps in our Getting Started Guide to integrate the SDK into your project.
Basic integration
- In your view controller's header file:
- Import the
INInterstitialAdController.hheader file and declare anINInterstitialAdController *interstitialproperty. - Declare that your view controller implements the
INInterstitialAdControllerDelegateprotocol.
- Import the
- In your view controller's implementation file, instantiate an
INInterstitialAdControllerusing the class convenience method+interstitialAdControllerForAdUnitId:, passing in your ad unit ID. - Register your view controller as the
interstitial's delegate. (e.g.self.interstitial.delegate = self;) - Pre-fetch the interstitial ad by calling
-loadAdon theinterstitial. - When you'd like to display the ad, check the ad's ready property.
- If the ad is ready to be shown, call
-showFromViewController:on theinterstitial, passing in your view controller.
Sample Code
// MyViewController.h
#import "INInterstitialAdController.h"
@interface MyViewController : UIViewController <INInterstitialAdControllerDelegate>
@property (nonatomic, retain) MPInterstitialAdController *interstitial;
@end
// MyViewController.h
#import "MyViewController.h"
@implementation MyViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.interstitial = [INInterstitialAdController
interstitialAdControllerForAdUnitId:@"YOUR_ADUNIT_ID"];
self.interstitial.delegate = self;
[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.
}
}
Delegates
You can recieve various delegagates call about interstitial status
Detecting When an Interstitial Ad is Loaded:
- (void)interstitialDidLoadAd:(INInterstitialAdController *)interstitial;
- (void)interstitialDidFailToLoadAd:(INInterstitialAdController *)interstitial;
Detecting When an Interstitial Ad is Presented
- (void)interstitialWillAppear:(INInterstitialAdController *)interstitial;
- (void)interstitialDidAppear:(INInterstitialAdController *)interstitial;
Detecting When an Interstitial Ad is Dismissed
- (void)interstitialWillDisappear:(INInterstitialAdController *)interstitial;
- (void)interstitialDidDisappear:(INInterstitialAdController *)interstitial;
- (void)interstitialDidReceiveTapEvent:(INInterstitialAdController *)interstitial;
A complete ViewController is available in sample app.