Interstitial ads are full-screen ads that cover the interface of an app until closed by the user. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.
This guide shows you how to integrate interstitial ads into an iOS app.
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account. The easiest way to load test ads is to use our dedicated test ad unit ID for app interstitial ads:
63a573a507ebe
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
Implementation
The main steps to integrating interstitial ads are:
Load an ad
Register for callbacks
Display the ad and handle the event
Load an ad
Loading an ad is accomplished using the static loadAdWithPlacementID: method on the Adx3InterstitialAd class. The load method requires your ad unit ID, a userId object, and a completion handler which gets called when ad loading succeeds or fails. userId object can not be passed or your custom user identifier. The below example shows how to load an Adx3InterstitialAd in your ViewController class.
importUIKitclassViewController:UIViewController, Adx3InterstitialDeleagte {overridefuncviewDidLoad() { super.viewDidLoad()loadInterstitialAd()// Do any additional setup after loading the view. }funcloadInterstitialAd() { Adx3InterstitialAd.sharedManager().load(withPlacementID: "Your Placement ID", userId: "", delegate: self) { isSuccess in
} }}
You should rely on the Adx3InterstitialDelegate (optional) to handle display events and request events. The following code shows how to implement the protocol:
Interstitials should be displayed during natural pauses in the flow of an app. Between levels of a game is a good example, or after the user completes a task. Here's an example of how to do this in one of the action methods in a UIViewController: