iOS Guidelines | Interstitial Ads

Interstitial ads are full page ads placed at natural break points in the app flow. With 10 times the real estate as compared to banner ads, Interstitials are guaranteed to catch your user's’ eye and drive higher revenue for your mobile business.

Follow these steps to start monetizing with Interstitial ads:

Setting up an Interstitial Ad

After adding your app, select INTERSTITIAL to create a placement for ad type Interstitial.

Once you create the Interstitial placement, you will have the placement id.

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 frameworks and declare an interstitial instance in your ViewController.swift file. Your ViewController file should look like this:
    import UIKit
    import InMobiSDK
    class ViewController: UIViewController, IMInterstitialDelegate {
        var interstitial: IMInterstitial?
    }
    		
  2. Instantiate the interstitial object. Your viewDidLoad method in ViewController.swift file should look like this:
    override func viewDidLoad() {
            super.viewDidLoad()
            interstitial = IMInterstitial.init(placementId: 1446377525790)
            interstitial?.delegate = self
            interstitial?.load()
    }
    		

    Important: Create only one object per placement ID and reuse it for subsequent ad loads.

  3. For ad status callbacks, implement the delegate property of IMInterstitial. The following callbacks are supported:
       /**
         * Notifies the delegate that the ad server has returned an ad. Assets are not yet available.
         * Please use interstitialDidFinishLoading: to receive a callback when assets are also available.
         */
        public func interstitialDidReceiveAd(_ interstitial: IMInterstitial!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial has finished loading and can be shown instantly.
         */
        public func interstitialDidFinishLoading(_ interstitial: IMInterstitial!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial has failed to load with some error.
         */
        public func interstitial(_ interstitial: IMInterstitial!, didFailToLoadWithError error: IMRequestStatus!) {
            NSLog("[ViewController %@]", #function)
            NSLog("Interstitial ad failed to load with error %@", error)
        }
        /**
         * Notifies the delegate that the interstitial would be presented.
         */
        public func interstitialWillPresent(_ interstitial: IMInterstitial!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial has been presented.
         */
        public func interstitialDidPresent(_ interstitial: IMInterstitial!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial has failed to present with some error.
         */
        public func interstitial(_ interstitial: IMInterstitial!, didFailToPresentWithError error: IMRequestStatus!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial will be dismissed.
         */
        public func interstitialWillDismiss(_ interstitial: IMInterstitial!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial has been dismissed.
         */
        public func interstitialDidDismiss(_ interstitial: IMInterstitial!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the interstitial has been interacted with.
         */
        public func interstitial(_ interstitial: IMInterstitial!, didInteractWithParams params: [AnyHashable : Any]!) {
            NSLog("[ViewController %@]", #function)
        }
        /**
         * Notifies the delegate that the user will leave application context.
         */
        public func userWillLeaveApplication(from interstitial: IMInterstitial!){
            NSLog("[ViewController %@]", #function)
        }
    		
  4. To show the Interstitial Ad, use the following code:
    interstitial?.show(from: self)
    //interstitial?.show(from: self, with:.coverVertical)
    		

    Here are the possible animation types:

    • coverVertical
    • flipHorizontal
    • none

Important:

  • Make sure that interstitialDidFinishLoading delegate is fired before making a call to show(from viewController: UIViewController!). Otherwise, the error callback interstitial(_ interstitial: IMInterstitial!, didFailToLoadWithError error: IMRequestStatus!) will be fired. Keep listening to the interstitial states to call show only when the ad is fully loaded.
  • 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.

Retrieving CreativeID

At times, there are rogue advertisers who escape all the ad quality checks and end up compromising the user experience on the app by showcasing either an irrelevant, distasteful or disrupting creative to the user. To combat such situations, you can retrieve the creativeID of the ad instance and report back to your InMobi point of contact with the encrypted creativeID.

mInterstitialAd.creativeId //mInterstitialAd is an example instance.

Testing the Integration

  1. Configure the test mode on InMobi portal.

    Go to Tools - Diagnostics and switch Test Mode to either Global ON or Selective ON.

    If you are integrating an ad unit for the first time Set Test Mode to Global ON.
    If you want to selectively turn on test traffic for a set of devices·

    You already have a prior version of the SDK integrated for this particular ad unit and therefore you should restrict your testing to only few devices
    Set Test Mode to Selective ON.

    In the device section:

    1. In the Device ID box, type the device ID.
    2. In the Device Name box, set any name.
    3. Click Add Device to add the test device.

    If you already have a device configured, you can select the device and test mode would be enabled.

    Note: You MUST turn off the test mode before going live or else your app will fail to monetize.

    Now you are all set to get test ads.

    Getting the Device ID

    The device id is basically the IDFA or IFA (Identifier for Advertising). To get device ID, the easiest approach is to set the log level of the SDK to “debug”. To enable debug logs, add this to didFinishLaunchingWithOptions method within the AppDelegate.swift file, as shown below:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions 
    launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            //Initialize InMobi SDK with your account ID
            IMSdk.initWithAccountID("Insert InMobi account ID here")
            IMSdk.setLogLevel(.debug)
            // Do your stuff.
            return true
        }
    		

    In the debug mode, the device ID will be logged on XCode developer console as: “Publisher device ID is <device-id>”

    You can enter this device id in the Device ID box.

  2. You will also get feedback on the diagnostics tab on the ad unit and ad request and this can be particularly helpful during integration.

  3. You should also see these key InMobi SDK logs in console when a interstitial ad is successfully loaded:

    [InMobi] InMobi SDK initialized with account id: <your account id here>

    [InMobi] Fetching interstitial ad for placement id: <your placement id here>

    [InMobi] Publisher device id is <device id here>

    [InMobi] Interstitial ad successfully fetched for placement id: <your placement id here>

  4. Now you would also see the InMobi test ads on your application.
  5. If the SDK is not initialised correctly before creating an ad, you would typically see these logs :

    ** ERROR ** [InMobi] ___ Please initialize the SDK before creating a <ad format> ad.

    ** ERROR ** [InMobi] ___ Account id cannot be null or empty. Please provide a valid Account id.

    [InMobi] Invalid account id passed to init. Please provide a valid account id.

The complete set of key logs are documented in the following tables.

SDK Initialization

Scenario Log Level Logs
Publisher passed null or empty account id Error Account id cannot be null or empty. Please provide a valid Account id.
Publisher passed a valid account id Debug InMobi SDK initialized with account id: <account id>
Publisher passed an invalid account Id Error Invalid account id passed to init. Please provide a valid account id.
Newer version of SDK is available Debug A newer version (ver. 6.0.0) of the InMobi SDK is available! You are currently on an older version (ver. 5.3.1). Download the latest InMobi SDK from http://www.inmobi.com/products/sdk/#downloads

Ads Common

Scenario Log Level Logs
Ad requested when no network available Error Network not reachable currently. Please try again.
Ad requested when ad state is loading or available Error An ad load is already in progress. Please wait for the load to complete before requesting for another ad (Placement id :<placement id> ).
Ad requested when ad is viewed by user Error An ad is currently being viewed by the user. Please wait for the user to close the ad before requesting for another ad (Placement id : <placement id> ).
Publisher device Id Debug Publisher device id is <Device Id>

Interstitial Ads

Scenario Log Level Logs
Publisher created an interstitial without initializing the SDK Error Please initialize the SDK before creating a interstitial ad
Publisher created an interstitial with an invalid placement id Error Please provide a valid placement id to create a interstitial ad
Publisher called load on an interstitial Debug Fetching an interstitial ad for placement id: <placement id>
Successfully fetched ad Debug Interstitial ad successfully fetched for placement id: <placement id>
Failed to fetch the ad Error Failed to fetch Interstitial ad for placement id:<Placement id> with error:<Status code / message>
Started loading the interstitial in a webview Debug Started loading Interstitial ad markup in the webview for placement id: <Placement id>
Interstitial successfully loaded in the webview Debug Successfully loaded Interstitial ad markup in the webview for placement id: <placement id>
Failed to load interstitial in the webview Error Failed to load the Interstitial markup in the webview for placement id: <placement id>
Interstitial Ad displayed Debug Successfully displayed Interstitial for placement id:<placement id>
Interstitial Ad dismissed Debug Interstitial ad dismissed for placement id:<placement id>
Ad show before ready Show ad before it's ready Error Ad Load is not complete. Please wait for the Ad to be in a ready state before calling show
Full screen ad cannot be displayed without a view controller. Please pass a view controller to present the full screen ad. Error Full screen ad cannot be displayed without a view controller. Please pass a view controller to present the full screen ad.