Interstitial Ads

We support both static and video interstitial ads. Follow the instructions below to set up interstitial ads.

Set up Interstitial Ad

  1. From the left navigation, select Inventory Inventory Settings.
  2. Search for the app or website you would like to create a placement for and click + Add a placement.
  3. Click Select Ad Unit and select Interstitial.
  4. Click Add a placement to start setting up your Interstitial settings.
  5. From there you can select your Ad Experience template. If you haven’t created an Ad Experience template yet, you can select the default Interstitial ad template created by InMobi which can contain both static and video creatives. You can always create your own template from Inventory Ad Experience Template. For more information, see Ad Experience Settings. After you create the Interstitial placement, you can see the placement ID.

Add Interstitial Ad to your App

Creating an Interstitial Ad

The IMInterstitial is simply a UIViewController subclass displaying full-screen ads that respond to user touch.

Follow these steps to create the interstitial ad unit programmatically:

  1. Import the headers and declare an interstitial instance in your ViewController.h / ViewController.swift file. Your ViewController header file should look like this:

    Objective C

    #import  <UIKit/UIKit.h> 
    @import InMobiSDK; 
    @interface ViewController : UIViewController <IMInterstitialDelegate> 
    @property (nonatomic, strong) IMInterstitial *interstitial; 
    @end
    

    Swift

    import UIKit
    import InMobiSDK
    class ViewController: UIViewController, IMInterstitialDelegate {
        var interstitial: IMInterstitial?
    }
    	
  2. Instantiate the interstitial object. Your viewDidLoad method in ViewController.m file should look like this:
     

    Objective C

    -(void)viewDidLoad { 
        [super viewDidLoad]; 
        self.interstitial = [[IMInterstitial alloc] initWithPlacementId:<Insert your placement ID here>]; 
        self. interstitial.delegate = self; 
        [self.interstitial load]; 
    } 
    

    Swift

    override func viewDidLoad() { 
        super.viewDidLoad() 
        interstitial = IMInterstitial.init(placementId: <Insert your placement ID here>) 
        interstitial?.delegate = self 
        interstitial?.load() 
    } 
    
  3. For ad status callbacks, implement the delegate methods of IMInterstitialDelegate. Here are the supported callbacks:

    Objective C

    // Notifies that the ad is received with Meta info. 
    - (void)interstitial:(IMInterstitial *)interstitial didReceiveWithMetaInfo:(IMAdsMetaInfo*)metaInfo { 
        NSLog(@"interstitial didReceiveAdWithMetaInfo"); 
    } 
    - (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial { 
        NSLog(@"interstitialDidFinishLoading"); 
    } 
    - (void)interstitial:(IMInterstitial *)interstitial didFailToLoadWithError:
    (IMRequestStatus *)error { 
        NSLog(@"Interstitial failed to load ad"); 
        NSLog(@"Error : %@",error.description); 
    } 
    - (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:
    (IMRequestStatus *)error { 
        NSLog(@"Interstitial didFailToPresentWithError"); 
        NSLog(@"Error : %@",error.description); 
    } 
    - (void)interstitialWillPresent:(IMInterstitial *)interstitial { 
        NSLog(@"interstitialWillPresent"); 
    } 
    - (void)interstitialDidPresent:(IMInterstitial *)interstitial { 
        NSLog(@"interstitialDidPresent"); 
    } 
    - (void)interstitialWillDismiss:(IMInterstitial *)interstitial { 
        NSLog(@"interstitialWillDismiss"); 
    } 
    - (void)interstitialDidDismiss:(IMInterstitial *)interstitial { 
        NSLog(@"interstitialDidDismiss"); 
    } 
    - (void)userWillLeaveApplicationFromInterstitial:(IMInterstitial *)interstitial { 
        NSLog(@"userWillLeaveApplicationFromInterstitial"); 
    } 
    - (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:
    (NSDictionary *)params { 
        NSLog(@"InterstitialDidInteractWithParams"); 
    }
    

    Swift

    public func interstitialDidReceiveAd(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitialDidFinishLoading(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitial(_ interstitial: IMInterstitial, didFailToLoadWithError error: IMRequestStatus) {
            print("[ViewController %@] \(#function)")
            print("Interstitial ad failed to load with error \(error)" )
        }
        public func interstitialWillPresent(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitialDidPresent(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitial(_ interstitial: IMInterstitial, didFailToPresentWithError error: IMRequestStatus) {
            print("[ViewController %@] \(#function)")
            print("Interstitial ad failed to present with error \(error)" )
        }
        public func interstitialWillDismiss(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitialDidDismiss(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitial(_ interstitial: IMInterstitial, didInteractWithParams params: [String : Any]?) {
            print("[ViewController %@] \(#function)")
        }
        public func interstitial(_ interstitial: IMInterstitial, rewardActionCompletedWithRewards rewards: [String : Any]) {
            print("[ViewController %@] \(#function)")
        }
        public func userWillLeaveApplicationFromInterstitial(_ interstitial: IMInterstitial) {
            print("[ViewController %@] \(#function)")
        }
    
  4. To show the Interstitial Ad, use the following code:

    Objective C

    [self.interstitial showFrom:self];
    [self.interstitial showFrom:self with:IMInterstitialAnimationTypeAsNone];
    
    

    Swift

    interstitial?.show(from: self)
    //interstitial?.show(from: self, with:.coverVertical)
    
    

Objective C

Here are the possible animation types:

  • IMInterstitialAnimationTypeCoverVertical
  • IMInterstitialAnimationTypeFlipHorizontal
  • IMInterstitialAnimationTypeAsNone

Important:

  • Make sure that interstitialDidFinishLoading callback is received before making a call to showFromViewController. Otherwise, the error callback interstitial:didFailToPresentScreenWithError: will be given.
  • Every time an interstitial ad is shown and subsequently dismissed, you will need to invoke [self.interstitial load]; again. Without this, you won't be able to call showFromViewController again.

Swift

Here are the possible animation types:

  • coverVertical
  • flipHorizontal
  • None

Important:

  • Make sure that interstitialDidFinishLoading callback is received before making a call to show(from viewController: UIViewController!). Otherwise, the error callback interstitial(_ interstitial: IMInterstitial!, didFailToLoadWithError error: IMRequestStatus!) will be given.
  • Every time an interstitial ad is shown and subsequently dismissed, you will need to invoke interstitial?.load() again. Without this, you won't be able to call show(from viewController: UIViewController!) again.

On This Page

Last Updated on: 07 Jun, 2023