Interstitial Ad
This article will go through all the steps required to display an Interstitial Ad in your application.
Interstitials Ads are skippable fullscreen ads.
Requirements
You have registered an application on your Ogury Dashboard. If not, please refer to the Getting Started section before the next steps.
Step 1: Create an Interstitial Ad ad unit
Copy the Ad unit id as you will need this information later to finish the integration.
In all the following code samples, we will refer to this Ad unit id by using the string AD_UNIT_ID
.
Step 2: Load an Interstitial Ad
The Ogury SDK provides the OguryInterstitialAd
object that lets you load, display and control your Interstitial Ads.
Instantiate an Interstitial Ad
Declare a
OguryInterstitialAd
instance variable in theViewController
where you want to display an Interstitial Ads:
In the
viewDidLoad
method of theViewController
, instantiate the Interstitial Ad:
OguryInterstitialAd
takes the following parameter:
an
adUnitID
: the Ad unit id of the Interstitial Ad. If you do not have one yet, you can refer to the first step to create it.
Load an Interstitial Ad
To start loading an ad, call the load
method:
Since it may take a few seconds to fetch the ad resources (video, image, ...) from the network, you should call the load
method as soon as possible after getting the user's consent.
Ideally, you should implement one of the two following examples depending on your use case:
Call the
load
method right after thestart
method in theViewController
that collects the consent:
Call the
load
method in theviewDidLoad
of your otherViewController
:
Additionally, if you want to follow the lifecycle of the Interstitial Ad, you can register a delegate.
Step 3: Show an Interstitial Ad
To display the ad, call show
method:
The show
method takes the following parameter:
a reference to the
ViewController
where you will show the Interstitial Ad.
If the method fails to show the ad, the following delegate is called:
The parameters of this callback are the following:
error
: the error which occurred while trying to display the ad. Error codes are explained below.interstitial
: the Interstitial Ad for which the error occurred.
Step 4: Test your integration
Ogury exclusively serves ads to users who have given consent. It is essential to have responded to a valid TCFv2 consent form before conducting any tests.
As our algorithm works with personified targeting, you may not receive any ad while testing your application.
You can test your integration by adding the suffix _test
to your interstitial ad unit id, for more details go to Test your implementation page.
Note that if you have just registered your application in the Ogury Dashboard, it will take around 15 minutes until you can successfully load an ad.
If you are not able to display any Interstitial Ad, we recommend you to log every delegate on OguryInterstitialAdDelegate
to follow the lifecycle of the Interstitial Ad.
If you encounter the didFailOguryInterstitialAdWithError
callback , you can check the error codes section below to understand the error and get some advice on how to solve the issue.
Advanced topics
Check if an ad is ready to be displayed
Call the following method to check if an Interstitial Ad is ready to be displayed:
If you want to be informed when the ad is ready to be displayed, you can also register a delegate and implement the didLoadOguryInterstitialAd
method.
Delegate
The Ogury SDK provides the OguryInterstitialAdDelegate
to listen to the lifecycle of an Interstitial Ad instance.
To register a OguryInterstitialAdDelegate
, add the following code just after instantiating the OguryInterstitialAd
:
The OguryInterstitialAdDelegate
exposes the following methods:
Methods | Definition |
| The SDK is ready to display the ad provided by the ad server. |
| The ad has been displayed on the screen. |
| The as has been clicked by the user. |
| The ad has been closed by the user. |
| The ad failed to load or display. The |
| The ad has triggered an impression. |
Error codes
When an ad fails to load or to be displayed, the SDK will call the didFailOguryInterstitialAdWithError
callback with one of error code defined in OguryAdsError
:
Name | Value | Definition |
|
| No Internet connection The device has no Internet connection. Try again once the device is connected to the Internet. |
|
| Ad disabled Ad serving has been disabled for this placement/application. |
|
| Profig not synchronized An internal SDK error has occurred. |
|
| Ad expired The loaded ad is expired. You must call the |
|
| SDK init not called The |
|
| Another ad already displayed Another ad is already displayed on the screen. |
|
| SDK init failed An error occurred during the initialization of the SDK. |
|
| Ad not available The server returns no ads. |
|
| A view controller is already being presented Only one view controller may be presented at a time. |
|
| Unknown error An unknown error occurred. |
Last updated