Skip to content

Interstitial Ads

The following sections show you how to load and then show an interstitial ad.

Loading an Interstitial Ad

The following code shows you how to load the first interstitial:

local interstitial_ad_unit_ids = {
android = "«android-ad-unit-ID»",
ios = "«ios-ad-unit-ID»"
}
function initialize_interstitial_ads()
local ad_unit_id
local sysinfo = sys.get_sys_info()
if sysinfo.system_name == "Android" then
ad_unit_id = interstitial_ad_unit_ids["android"]
elseif sysinfo.system_name == "iPhone OS" then
ad_unit_id = interstitial_ad_unit_ids["ios"]
end
applovin.load_interstitial(ad_unit_id)
-- Interstitial Ad Callbacks
local function applovin_callback(self, name, params)
if name == "OnInterstitialAdLoadedEvent" then
-- Interstitial ad is ready to be shown. applovin.is_interstitial_ready(ad_unit_id) will now return true
if name == "OnInterstitialAdLoadFailedEvent" then
if name == "OnInterstitialAdDisplayedEvent" then
if name == "OnInterstitialAdDisplayFailedEvent" then
if name == "OnInterstitialAdClickedEvent" then
if name == "OnInterstitialAdHiddenEvent" then
if name == "OnInterstitialAdRevenuePaidEvent" then

Showing an Interstitial Ad

To show an interstitial ad, call show_interstitial():

if applovin.is_interstitial_ready(«ad-unit-ID») then
applovin.show_interstitial(«ad-unit-ID»)