Integrating Interstitial Ads

Document created by david.simerly on Oct 20, 2017Last modified by david.simerly on Apr 3, 2018
Version 12Show Document
  • View in full screen mode

PubMatic SDKs 

PubMatic iOS SDK 

Getting Started

Integrating Banner Ads

➤  Integrating Interstitial Ads

Rich Media (MRAID 2.0) Support

Integrating Native Ads

Header Bidding With DFP

Passing Targeting Information

SDK Debugging


PubMatic iOS SDK Reference 

Interstitial ads are full-screen ads displayed at transition points in an app; for example, when the app launches, when moving between screens, and so on. Interstitial ads exhibit the following behavior:

 

  • Always includes a Close button; either immediately, or shortly after, the ad displays.
  • One-time ad; once the ad is closed the same PMInterstitialAd object cannot display it again.

 

You'll need to follow the instructions in Getting started before proceeding with the following integration steps. You'll also find a useful example integration in SampleApp included in the SDK download bundle.

          

 

Once you've downloaded and installed the PubMatic iOS SDK, use the following sections to implement and configure Interstitial ads:

 

 

Display Interstitial Ad

Use the following steps to include Interstitial ads into your application:

 

Step 1: Import PMInterstitialAd.h header file

 

#import "PMInterstitialAd.h"

 

The import statements may differ for different integration methods.

 

Step 2: Setup Interstitial Ad

A. Create an instance of PMInterstitialAd.

B. Set the delegate property of PMInterstitialAd's instance to PMInterstitialAdDelegatein your view controller.

C. Implement delegate callbacks:

 

    #import <InterstitialViewController.h>
    #import "PMInterstitialAd.h"

    // InterstitialViewController.m

    @interface InterstitialViewController ()<PMInterstitialAdDelegate>
    @property (nonatomic, retain) PMInterstitialAd * interstitialAd;
    @end

    @implementation InterstitialViewController
    - (void)viewDidLoad{

        self.interstitialAd = [[ PMInterstitialAd  alloc] init];
        self.interstitialAd.delegate = self;
    }
    @end

 

Step 3: Create an Interstitial Ad Request

After you have set up a InterstitialAd object, create an instance of PMInterstitialAdRequest:

 

PMInterstitialAdRequest * adRequest = [[PMInterstitialAdRequest alloc] initWithPublisherId:@"<#PUB_ID#>" 
                                                                       siteId:@"<#SITE_ID#>"
                                                                       adId:@"<#AD_ID#>"];

 

Step 4: Request Ad

Request an Interstitial ad from PubMatic:

 

// Make the ad request to PubMatic  
[self.interstitialAd loadRequest:adRequest];

 

Step 5: Receive PMInterstitialAdDelegate callbacks, then present the Interstitial ad

PubMatic SDK provides PMInterstitialAdDelegate through which your app can receive ad event callbacks:

 

// PMInterstitialAdDelegate methods
- (void)interstitialAd:( PMInterstitialAd  *)interstitialAd didFailToReceiveAdWithError:(PMError *)error{
    NSLog(@"Error - %@", error.localizedDescription);
}

- (void)interstitialAdDidRecieveAd:(PMInterstitialAd *)interstitialAd{
    if ([interstitialAd isReady]) {
        [interstitialAd show];
    }
}

@end

 

See PubMatic SDK Error Codes for a detailed description of the PMError object used in the interstitialAd:didFailToReceiveAdWithError: callback.

 

Best Practices

  • Determine whether the Interstitial ad is ready using the isReady method of the PMInterstitialAd object, as shown in step 5 above before displaying it.
  • Call the show or showForDuration: method of the PMInterstitialAd object to display the ad in full-screen. The ad displays only after it successfully loads.
  • Remember that an Interstitial ad is a one-time ad; your app can show it only once. To request another ad, call loadRequest: again or create a new PMInterstitialAd instance to request a new ad.

 

To fully support all MRAID events please follow the steps in Rich Media (MRAID 2.0) Support.

 

Attachments

    Outcomes