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
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.
If you are a mediation, you should provide an extra parameter OguryMediation
that should be instanciated with :
Your current mediation name as
MEDIATION_NAME
Your current SDK version as
YOUR_SDK_VERSION
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.
Make sure to call the show
method in the main thread, otherwise, an exception will result.
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:
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
:
Last updated