Page Summary
-
Rewarded interstitial ads offer rewards for ads displayed during natural app transitions without requiring user opt-in.
-
Integrating rewarded interstitial ads involves loading an ad, optionally validating SSV callbacks, registering for callbacks, displaying the ad, and handling the reward event.
-
You must present an intro screen before displaying a rewarded interstitial ad that provides clear reward messaging and an option to skip the ad.
-
When presenting the ad, you need a
GADUserDidEarnRewardHandlerobject to manage the user's reward.
Rewarded interstitial is a type of incentivized ad format that allows you offer rewards for ads that appear automatically during natural app transitions. Unlike rewarded ads, users aren't required to opt-in to view a rewarded interstitial.
Prerequisites
Before you continue, set up Google Mobile Ads SDK .
Implementation
The primary steps to integrate rewarded interstitial ads are as follows:
- Load an ad
- [Optional] Validate SSV callbacks
- Register for callbacks
- Display the ad and handle the reward event
Load an ad
Loading an ad is accomplished using the load(adUnitID:request)
method on the GADRewardedInterstitialAd
class.
Swift
SwiftUI
import
GoogleMobileAds
class
RewardedInterstitialViewModel
:
NSObject
,
ObservableObject
,
FullScreenContentDelegate
{
@
Published
var
coins
=
0
private
var
rewardedInterstitialAd
:
RewardedInterstitialAd
?
func
loadAd
()
async
{
do
{
rewardedInterstitialAd
=
try
await
RewardedInterstitialAd
.
load
(
with
:
"ca-app-pub-3940256099942544/6978759866"
,
request
:
Request
())
rewardedInterstitialAd
?.
fullScreenContentDelegate
=
self
}
catch
{
print
(
"Failed to load rewarded interstitial ad with error:
\(
error
.
localizedDescription
)
"
)
}
}
Objective-C
Replace adUnitID with your ad unit ID.
[Optional] Validate server-side verification (SSV) callbacks
Apps that require extra data in server-side
verification
callbacks should use the
custom data feature of rewarded ads. Any string value set on a rewarded ad
object is passed to the custom_data
query parameter of the SSV callback. If no
custom data value is set, the custom_data
query parameter value won't be
present in the SSV callback.
The following code sample demonstrates how to set custom data on a rewarded interstitial ad object before requesting an ad.
Swift
Objective-C
Replace SAMPLE_CUSTOM_DATA_STRING with your custom data.
Register for callbacks
To receive notifications for presentation events, you must assign the GADFullScreenContentDelegate
to the fullScreenContentDelegate
property of
the returned ad:
Swift
rewardedInterstitialAd
?.
fullScreenContentDelegate
=
self
.
swift

