Rewarded
Rewarded video ads are immersive, full-screen video advertisements that provide users with the choice to watch them entirely. In return for their time and attention, users receive in-app rewards or benefits.
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:
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 example
The code sample below demonstrates how to utilize the Rewarded. In this example, you'll create an instance of an Rewarded, load an ad into it using an AdRequest, and enhance functionality by handling various life cycle events.
Load an ad
To load an rewarded ad, utilize the RewardedAdLoader
class. Pass in an RewardedAdLoadCallback
to receive the loaded ad or any potential errors. It's worth noting that, similar to other format load callbacks, the RewardedAdLoadCallback
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 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 RewardedAd
. Before presenting the RewardedAd
, ensure that you configure the callback:
Show the ad
When presenting a rewarded ad, you'll employ an OnUserEarnedRewardListener
object to manage reward-related events.
Clean up memory
Upon completion of an RewardedAd
, 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