Rewarded interstitial
A Rewarded Interstitial is a specific form of incentivized ad format that allows you to provide rewards in exchange for ads that appear automatically during natural app transitions. Unlike regular rewarded ads, users are not obligated to actively opt in to view a Rewarded Interstitial; they are seamlessly integrated into the app experience.
This document is based on:
Prerequisites
- Complete the Get started guide
Always test with test ads
When developing and testing your Godot apps, it's crucial to use test ads rather than live production ads. Failure to do so can result in the suspension of your AdMob account.
The most straightforward method to load test ads is by utilizing our dedicated test ad unit ID for Android and iOS rewarded interstitial:
This particular ad unit ID has been purposefully configured to deliver test ads for every request. You can safely employ it during your coding, testing, and debugging phases. However, remember to replace this test ad unit ID with your own when you are ready to publish your app.
For a more comprehensive understanding of how the Mobile Ads SDK's test ads function, please refer to our documentation on Test Ads.
Rewarded interstitial example
The code sample below demonstrates how to utilize the Rewarded interstitial. In this example, you'll create an instance of an Rewarded interstitial, load an ad into it using an AdRequest, and enhance functionality by handling various life cycle events.
Load an ad
To load an rewarded interstitial ad, utilize the RewardedInterstitialAdLoader
class. Pass in an RewardedInterstitialAdLoadCallback
to receive the loaded ad or any potential errors. It's worth noting that, similar to other format load callbacks, the RewardedInterstitialAdLoadCallback
leverages LoadAdError
to provide comprehensive error details.
[Optional] Validate server-side verification (SSV) callbacks
For apps that necessitate additional data in server-side verification Android/iOS callbacks, the custom data feature of rewarded ads can be employed. Any string value assigned to a rewarded ad object is transmitted to the custom_data
query parameter of the SSV callback. If no custom data is set, the custom_data
query parameter will be absent in the SSV callback.
The following code snippet illustrates how to establish custom data on a rewarded interstitial ad object before soliciting an ad:
Note
The custom reward string is percent escaped and might require decoding when parsed from the SSV callback.
Configure the FullScreenContentCallback
The FullScreenContentCallback
manages events associated with the display of your RewardedInterstitialAd
. Before presenting the RewardedInterstitialAd
, ensure that you configure the callback:
Show the ad
When presenting a rewarded interstitial ad, you'll employ an OnUserEarnedRewardListener
object to manage reward-related events.
Clean up memory
Upon completion of an RewardedInterstitialAd
, it's important to invoke the destroy()
function before releasing your reference to it:
This action signals to the plugin that the object is no longer in use and that the memory it occupies can be reclaimed. Neglecting to call this method can lead to memory leaks.
Further References
Samples
- Sample Project: A Minimal Illustration of usage of all Ad Formats