AI-generated Key Takeaways
-
Interstitial ads are full-screen ads displayed at natural transition points in an app.
-
Always use test ad unit IDs when building and testing your apps to avoid account suspension.
-
Integrating interstitial ads involves loading an ad, registering for callbacks, and displaying the ad.
-
Load interstitial ads in advance to ensure they are ready to be shown without delay.
-
Display interstitial ads during natural pauses and avoid flooding the user with too many ads.
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. Case study .
This guide shows you how to integrate interstitial ads into an iOS app.
Prerequisites
- Complete the Get started guide .
Always test with test ads
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 iOS interstitials: ca-app-pub-3940256099942544/4411468910
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.
For more information about how the Mobile Ads SDK's test ads work, see Test Ads .
Implementation
The main steps to integrate interstitial ads are:
- Load an ad.
- Register for callbacks.
- Display the ad.
Load an ad
Loading an ad is accomplished using the load(adUnitID:request)
method on the GADInterstitialAd
class.
Swift
fileprivate
func
loadInterstitial
()
async
{
do
{
interstitial
=
try
await
InterstitialAd
.
load
(
with
:
"ca-app-pub-3940256099942544/4411468910"
,
request
:
Request
())
interstitial
?.
fullScreenContentDelegate
=
self
}
catch
{
print
(
"Failed to load interstitial ad with error:
\(
error
.
localizedDescription
)
"
)
}
}
SwiftUI
import
GoogleMobileAds
class
InterstitialViewModel
:
NSObject
,
FullScreenContentDelegate
{
private
var
interstitialAd
:
InterstitialAd
?
func
loadAd
()
async
{
do
{
interstitialAd
=
try
await
InterstitialAd
.
load
(
with
:
"ca-app-pub-3940256099942544/4411468910"
,
request
:
Request
())
interstitialAd
?.
fullScreenContentDelegate
=
self
}
catch
{
print
(
"Failed to load interstitial ad with error:
\(
error
.
localizedDescription
)
"
)
}
}
Objective-C
[
GADInterstitialAd
loadWithAdUnitID
:
@"ca-app-pub-3940256099942544/4411468910"
request
:[
GADRequest
request
]
completionHandler
:
^
(
GADInterstitialAd
*
ad
,
NSError
*
error
)
{
if
(
error
)
{
NSLog
(
@"Failed to load interstitial ad with error: %@"
,
[
error
localizedDescription
]);
return
;
}
self
.
interstitial
=
ad
;
self
.
interstitial
.
fullScreenContentDelegate
=
self
;
}];
Register for callbacks
In order to receive notifications for presentation events, you must assign the GADFullScreenContentDelegate
to the fullScreenContentDelegate
property of
the returned ad:
Swift
interstitial
?.
fullScreenContentDelegate
=
self
.
swift

