Skip to main content

Getting Started

Interstitial ads are full-screen ads that cover the entire display area.

Sample Image

Prerequisites

Adding Dependencies

To use interstitial ads, add the GFPSDK/MediationNDARich module to your Podfile.

# When using static library
pod 'GFPSDK/MediationNDARich'

# When using dynamic library
pod 'GFPSDK-Dynamic/MediationNDARich'

NAMSDK Import

Import the SDK module.

import GFPSDK

Initializing Interstitial Ad Providers

With the Pod for the interstitial ad provider you want to integrate added to your project, initialize via GFPAdManager. (Perform this only once when the app starts.)

Provider OptionAd ProviderCocoaPods
GFPInterstitialAdProviderOptionNDANaver NDApod 'GFPSDK/MediationNDA'
GFPInterstitialAdProviderOptionDFPGoogle GAM (Google Ad Manager)pod 'GFPSDKMediationDFP'
GFPInterstitialAdProviderOptionFANMeta Audience Networkpod 'GFPSDKMediationFAN'
GFPInterstitialAdProviderOptionUnityUnity Adspod 'GFPSDKMediationUnity'
GFPInterstitialAdProviderOptionAppLovinAppLovin MAXpod 'GFPSDKMediationAppLovin'
GFPInterstitialAdProviderOptionVungleLiftoff (Vungle)pod 'GFPSDKMediationVungle'
GFPInterstitialAdProviderOptionDTDigital Turbinepod 'GFPSDKMediationDT'
GFPInterstitialAdProviderOptionISIronSourcepod 'GFPSDKMediationIronSource'
GFPInterstitialAdProviderOptionLANLINE Ads Networkpod 'GFPSDKMediationLAN'
GFPInterstitialAdProviderOptionChartBoostChartboostpod 'GFPSDKMediationChartBoost'
GFPInterstitialAdProviderOptionBidMachineBidMachinepod 'GFPSDKMediationBidMachine'
GFPInterstitialAdProviderOptionPanglePanglepod 'GFPSDKMediationPangle'
info

S2S interstitial ads do not require separate provider initialization.

// Add cocoapods dependencies if integrating DFP, Facebook interstitial ads.
GFPAdManager.setup(withPublisherCd: "publisherCd") { (error : GFPError?) in
print("Setup Eror: \(String(describing: error?.description))")
}
tip

For details on configuring GFPAdManager, refer to Ad Manager Setup.

Implementing a View Controller

Create a view controller (MyViewController) and perform the following steps in the header file (MyViewController.h).
(In this example, the view controller owns the manager.)

  1. Declare a *GFPInterstitialAdManager adManager property in the view controller.
  2. Implement the GFPInterstitialAdManagerDelegate protocol in the view controller.

GFPInterstitialAdManagerDelegate delivers the load status, failure status, and click events of interstitial ads.

// MyViewController.h
import GFPSDK

class MyViewController : UIViewController, GFPInterstitialAdManagerDelegate {
private var adManager : GFPInterstitialAdManager?
}

GFPInterstitialAdManager Usage Guide

Creating GFPInterstitialAdManager and Requesting an Ad Load

In the viewDidLoad method of MyViewController.m, create an instance of GFPInterstitialAdManager and request an ad.

  • After creating the instance, make sure to set the delegate.
  • When creating a GFPInterstitialAdManager instance, provide the Ad Unit ID you received along with user information in GFPAdParam. GFPAdParam is used for targeting to improve ad performance.
override func viewDidLoad() {
super.viewDidLoad()

let adParam = GFPAdParam()
adParam.yearOfBirth = 1990
adParam.gender = .male
...

//Create instance
self.adManager = GFPInterstitialAdManager(unitID: "UnitID", adParam: adParam)
//Delegate
self.adManager?.delegate = self
//Timeout
self.adManager?.requestTimeoutInterval = 60
//Request ad
self.adManager?.load()
}
tip

This manager is designed for one-time use per ad load and response. When loading a new ad, create a new manager instance.

tip

When an ad request succeeds, the GFPInterstitialAdManagerDelegate interstitialAdManager:didLoadAd: method is called.

Requesting Ad Display

If you receive a success response via GFPInterstitialAdManagerDelegate interstitialAdManager:didLoadAd:, you can request ad display using the show:(UIViewController *) method.

Checking if Ad is Loaded

You can use the isAdLoaded property to check whether an ad has been loaded.

if self.adManager?.isAdLoaded == true {
// The ad is in a loaded state.
}

Checking for Ad Invalidation

When displaying a preloaded and cached ad, you must use the isAdInvalidate method to check whether the ad has expired. If you display an expired ad, you will not receive compensation for the ad impression.

if interstitialdAd.isAdInvalidate {
self.adManager?.show(self)
}
tip

When requesting ad display, if the display fails, the GFPInterstitialAdManagerDelegate interstitialAdManager:didFailWithError:responseInfo: method is called.

tip

Since ad loading and ad display are separate, you can implement a flow where you load first and then display later. The validity period of a loaded ad is DFP, FAN: 60 minutes.

GFPInterstitialAdManagerDelegate

By implementing GFPInterstitialAdManagerDelegate, you can receive interstitial ad events through the corresponding methods.

Load Events

On Load Success

func interstitialAdManager(_ manager: GFPInterstitialAdManager, didLoad interstitialAd: GFPInterstitialAd) {
...
}

On Load Failure

func interstitialAdManager(_ manager: GFPInterstitialAdManager, didFailWithError error: GFPError, responseInfo: GFPLoadResponseInfo!) {
...
}
tip

Not only load failures, but also display failures, expiration, and other failure events are all delivered through this method.

LifeCycle Event

On Ad View Start

func interstitialAdManager(_ manager: GFPInterstitialAdManager, didStart interstitialAd: GFPInterstitialAd) {
...
}

On Ad View Complete

func interstitialAdManager(_ manager: GFPInterstitialAdManager, didComplete interstitialAd: GFPInterstitialAd) {
...
}

On Ad View Dismissed

func interstitialAdManager(_ manager: GFPInterstitialAdManager, didClose interstitialAd: GFPInterstitialAd) {
...
}

On Ad Clicked

func interstitialAdManager(_ manager: GFPInterstitialAdManager, wasClickedAd interstitialAd: GFPInterstitialAd) {
...
}
tip

DFP version 7.x.x does not support click events, so this event will not be delivered.

The following methods are @optional delegate methods. You can implement them selectively as needed.

On Ad Impression

func interstitialAdManagerDidReceiveImpression(_ manager: GFPInterstitialAdManager) { ... }

On In-App Browser Opened

func interstitialAdManagerDidPresentDefaultInAppBrowser(_ manager: GFPInterstitialAdManager) { ... }

On In-App Browser Closed

func interstitialAdManagerDidDismissDefaultInAppBrowser(_ manager: GFPInterstitialAdManager) { ... }