Rewarded Video Ads
Rewarded ad units enable users to play games, take surveys, or watch videos to earn in-app rewards, such as coins, extra lives, or points. You can set different rewards for different ad units, and specify the reward values and items users will receive.
Benefits of Rewarded Video Ads
- Increase revenue, Rewarded video ads can increase your app revenue by 20% to 40%. eCPM for rewarded videos is the highest when compared to other types of mobile video ads.
- Increase in-app purchases, Rewarded video ads encourage free users to make in-app purchases by giving them a taste of premium features they’re missing. Users who watch rewarded video ads are six times more likely to make in-app purchases.
- Increase user engagement and retention, Users prefer watching reward video ads to paying for premium features. This encourages them to continue playing your game for longer, which in turn increases retention, engagement, and LTV.
You should finish these steps before releasing.
Load the ad
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
- Cocos2D
- React Native
Yodo1U3dRewardAd.GetInstance().LoadAd();
Yodo1MasRewardAd.getInstance().loadAd(MainActivity.this);
Yodo1MasRewardAd.getInstance().loadAd(this@MainActivity)
Yodo1MasRewardAd.sharedInstance().load()
[[Yodo1MasRewardAd sharedInstance] loadAd];
// Rewarded video ads are loaded automatically
Yodo1Ads.getInstance().initializeRewardAds();
// Rewarded video ads are pre-loaded automatically
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
- React Native
// Remember to call this function before SDK init.
Yodo1U3dRewardAd.GetInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasRewardAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasRewardAd.getInstance().autoDelayIfLoadFail = true
// Remember to call this function before SDK init.
Yodo1MasRewardAd.sharedInstance().autoDelayIfLoadFail = true
// Remember to call this function before SDK init.
[Yodo1MasRewardAd sharedInstance].autoDelayIfLoadFail = YES;
// No need to configure on Godot
// No need to configure on React Native
Display the ad
You can show the ad using this code, but we recommend using the ad events as you’ll be able to show the ad once it’s loaded. You can check the full script provided below.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
- Cocos2D
- React Native
bool isLoaded = Yodo1U3dRewardAd.GetInstance().IsLoaded();
// Show ad without placement name
if (isLoaded)
{
Yodo1U3dRewardAd.GetInstance().ShowAd();
}
// Show ad with placement name, like app_start, level_end
if (isLoaded)
{
Yodo1U3dRewardAd.GetInstance().ShowAd("Your placement ID");
}
boolean isLoaded = Yodo1MasRewardAd.getInstance().isLoaded();
// Show ad without placement name
if (isLoaded) Yodo1MasRewardAd.getInstance().showAd(this);
// Show ad with placement name, like app_start, level_end
if (isLoaded) Yodo1MasRewardAd.getInstance().showAd(this, "Your placement ID");
val isLoaded = Yodo1MasRewardAd.getInstance().isLoaded()
// Show ad without placement name
if (isLoaded) Yodo1MasRewardAd.getInstance().showAd(this@MainActivity)
// Show ad with placement name, like app_start, level_end
if (isLoaded) Yodo1MasRewardAd.getInstance().showAd(this@MainActivity, "Your placement ID")
let isLoaded = Yodo1MasRewardAd.sharedInstance().isLoaded()
// Show ad without placement name
if isLoaded { Yodo1MasRewardAd.sharedInstance().show() }
// Show ad with placement name, like app_start, level_end
if isLoaded { Yodo1MasRewardAd.sharedInstance().show(withPlacement: "Your placement ID") }
BOOL isLoaded = [[Yodo1MasRewardAd sharedInstance] isLoaded];
// Show ad without placement name
if (isLoaded) [[Yodo1MasRewardAd sharedInstance] showAd];
// Show ad with placement name, like app_start, level_end
if (isLoaded) [[Yodo1MasRewardAd sharedInstance] showAdWithPlacement:@"Your placement ID"];
yodo1mas.show_rewarded_ad()
Yodo1Ads.getInstance().showRewardAds();
// Recommended, add a placement ID to rewarded ads
Yodo1MASAds.showRewardedAdsWithPlacementId('Your placement ID');
// Show rewarded ads with no placement ID
Yodo1MASAds.showRewardedAds();
Configure the ad events
The MAS SDK fires several events to inform you of ad availability.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
- Cocos2D
- React Native
using Yodo1.MAS;
using System;
public class RewardAdLoader : MonoBehaviour
{
private int retryAttempt = 0;
private void Start()
{
SetupEventCallbacks();
LoadRewardAd();
}
private void SetupEventCallbacks()
{
Yodo1U3dRewardAd.GetInstance().OnAdLoadedEvent += OnRewardAdLoadedEvent;
Yodo1U3dRewardAd.GetInstance().OnAdLoadFailedEvent += OnRewardAdLoadFailedEvent;
Yodo1U3dRewardAd.GetInstance().OnAdOpenedEvent += OnRewardAdOpenedEvent;
Yodo1U3dRewardAd.GetInstance().OnAdOpenFailedEvent += OnRewardAdOpenFailedEvent;
Yodo1U3dRewardAd.GetInstance().OnAdClosedEvent += OnRewardAdClosedEvent;
Yodo1U3dRewardAd.GetInstance().OnAdEarnedEvent += OnRewardAdEarnedEvent;
}
private void LoadRewardAd()
{
Yodo1U3dRewardAd.GetInstance().LoadAd();
}
private void OnRewardAdLoadedEvent(Yodo1U3dRewardAd ad)
{
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
Yodo1U3dRewardAd.GetInstance().ShowAd();
}
private void OnRewardAdLoadFailedEvent(Yodo1U3dRewardAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad request fails.
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
Invoke("LoadRewardAd", (float) retryDelay);
}
private void OnRewardAdOpenedEvent(Yodo1U3dRewardAd ad)
{
// Code to be executed when an ad opened
}
private void OnRewardAdOpenFailedEvent(Yodo1U3dRewardAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad open fails.
LoadRewardAd();
}
private void OnRewardAdClosedEvent(Yodo1U3dRewardAd ad)
{
// Code to be executed when the ad closed
LoadRewardAd();
}
private void OnRewardAdEarnedEvent(Yodo1U3dRewardAd ad)
{
// Code executed when getting rewards
}
}
public class RewardActivity extends Activity implements Yodo1MasRewardAdListener {
private final Handler handler = new Handler(Looper.getMainLooper());
private int retryAttempt;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reward);
Yodo1MasRewardAd.getInstance().setAdListener(this);
Yodo1MasRewardAd.getInstance().autoDelayIfLoadFail = true;
Yodo1MasRewardAd.getInstance().loadAd(this);
}
@Override
public void onRewardAdLoaded(Yodo1MasRewardAd ad) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
// Show ad without placement name
Yodo1MasRewardAd.getInstance().showAd(this);
// Show ad with placement name, like app_start, level_end
// Yodo1MasRewardAd.getInstance().showAd(this, "Your placement ID");
}
@Override
public void onRewardAdFailedToLoad(Yodo1MasRewardAd ad, @NonNull Yodo1MasError error) {
// Code to be executed when an ad request fails.
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis((long) Math.pow(2, Math.min(5, retryAttempt)));
handler.postDelayed(new Runnable() {
@Override
public void run() {
Yodo1MasRewardAd.getInstance().loadAd(this);
}
}, delayMillis);
}
@Override
public void onRewardAdOpened(Yodo1MasRewardAd ad) {
// Code to be executed when an ad opened
}
@Override
public void onRewardAdFailedToOpen(Yodo1MasRewardAd ad, @NonNull Yodo1MasError error) {
// Code to be executed when an ad open fails.
Yodo1MasRewardAd.getInstance().loadAd(this);
}
@Override
public void onRewardAdClosed(Yodo1MasRewardAd ad) {
// Code to be executed when the ad closed
Yodo1MasRewardAd.getInstance().loadAd(this);
}
@Override
public void onRewardAdEarned(Yodo1MasRewardAd ad) {
// Code executed when getting rewards
}
}
class RewardActivity: Activity(), Yodo1MasRewardAdListener {
private val handler = Handler(Looper.getMainLooper()!!)
private var retryAttempt = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_reward)
Yodo1MasRewardAd.getInstance().setAdListener(this)
Yodo1MasRewardAd.getInstance().autoDelayIfLoadFail = true
Yodo1MasRewardAd.getInstance().loadAd(this)
}
override fun onRewardAdLoaded(ad: Yodo1MasRewardAd) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0
// Show ad without placement name
Yodo1MasRewardAd.getInstance().showAd(this)
// Show ad with placement name, like app_start, level_end
// Yodo1MasRewardAd.getInstance().showAd(this, "Your placement ID")
}
override fun onRewardAdFailedToLoad(ad: Yodo1MasRewardAd, error: Yodo1MasError) {
// Code to be executed when an ad request fails.
retryAttempt++
val delayMillis = TimeUnit.SECONDS.toMillis(2.toDouble().pow(5.coerceAtMost(retryAttempt)).toLong())
handler.postDelayed({
Yodo1MasRewardAd.getInstance().loadAd(this)
}, delayMillis)
}
override fun onRewardAdOpened(ad: Yodo1MasRewardAd) {
// Code to be executed when an ad opened
}
override fun onRewardAdFailedToOpen(ad: Yodo1MasRewardAd, error: Yodo1MasError) {
// Code to be executed when an ad open fails.
Yodo1MasRewardAd.getInstance().loadAd(this)
}
override fun onRewardAdClosed(ad: Yodo1MasRewardAd) {
// Code to be executed when the ad closed
Yodo1MasRewardAd.getInstance().loadAd(this)
}
override fun onRewardAdEarned(ad: Yodo1MasRewardAd) {
// Code executed when getting rewards
}
}
class RewardController: UIViewController {
private var retryAttempt = 0
override func viewDidLoad() {
super.viewDidLoad();
Yodo1MasRewardAd.sharedInstance().autoDelayIfLoadFail = true
Yodo1MasRewardAd.sharedInstance().adDelegate = self
Yodo1MasRewardAd.sharedInstance().load()
}
}
extension RewardController:Yodo1MasRewardDelegate {
func onRewardAdLoaded(_ ad: Yodo1MasRewardAd) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0
// Show ad without placement name
Yodo1MasRewardAd.sharedInstance().show()
// Show ad with placement name, like app_start, level_end
// Yodo1MasRewardAd.sharedInstance().show(withPlacement: "Your placement ID")
}
func onRewardAdFailed(toLoad ad: Yodo1MasRewardAd, withError error: Yodo1MasError) {
// Code to be executed when an ad request fails.
retryAttempt+=1
let delaySec = NSDecimalNumber(decimal: pow(2, min(5, retryAttempt))).doubleValue
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delaySec) {
Yodo1MasRewardAd.sharedInstance().load()
}
}
func onRewardAdOpened(_ ad: Yodo1MasRewardAd) {
// Code to be executed when an ad opened
}
func onRewardAdFailed(toOpen ad: Yodo1MasRewardAd, withError error: Yodo1MasError) {
// Code to be executed when an ad open fails.
Yodo1MasRewardAd.sharedInstance().load()
}
func onRewardAdClosed(_ ad: Yodo1MasRewardAd) {
// Code to be executed when the ad closed
Yodo1MasRewardAd.sharedInstance().load()
}
func onRewardAdEarned(_ ad: Yodo1MasRewardAd) {
// Code executed when getting rewards
}
}
@interface RewardViewController()<Yodo1MasRewardDelegate>
@property (nonatomic, assign) NSInteger retryAttempt;
@end
@implementation RewardViewController
- (void)viewDidLoad {
[super viewDidLoad];
[Yodo1MasRewardAd sharedInstance].adDelegate = self;
[Yodo1MasRewardAd sharedInstance].autoDelayIfLoadFail = YES;
[[Yodo1MasRewardAd sharedInstance] loadAd];
}
#pragma mark - Yodo1MasRewardDelegate
- (void)onRewardAdLoaded:(Yodo1MasRewardAd *)ad {
// Code to be executed when an ad finishes loading.
_retryAttempt = 0;
// Show ad without placement name
[[Yodo1MasRewardAd sharedInstance] showAd];
// Show ad with placement name, like app_start, level_end
// [[Yodo1MasRewardAd sharedInstance] showAdWithPlacement:@"Your placement ID"];
}
- (void)onRewardAdFailedToLoad:(Yodo1MasRewardAd *)ad withError:(Yodo1MasError *)error {
// Code to be executed when an ad request fails.
_retryAttempt++;
NSInteger delaySec = pow(2, MIN(5, self.retryAttempt));
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[Yodo1MasRewardAd sharedInstance] loadAd];
});
}
- (void)onRewardAdOpened:(Yodo1MasRewardAd *)ad {
// Code to be executed when an ad opened
}
- (void)onRewardAdFailedToOpen:(Yodo1MasRewardAd *)ad withError:(Yodo1MasError *)error {
// Code to be executed when an ad open fails.
[[Yodo1MasRewardAd sharedInstance] loadAd];
}
- (void)onRewardAdClosed:(Yodo1MasRewardAd *)ad {
// Code to be executed when the ad closed
[[Yodo1MasRewardAd sharedInstance] loadAd];
}
- (void)onRewardAdEarned:(Yodo1MasRewardAdAd *)ad {
// Code executed when getting rewards
}
@end
To show App Open Ads, just enable the AppOpenAds checkbox in the editor as shown in the screenshot.
Note : App Open Ads option will only work once the game is live.
public onRewardAdLoaded() {
}
public onRewardAdFailedToLoad() {
}
public onRewardAdOpened() {
}
public onRewardAdFailedToOpen() {
}
public onRewardAdClosed() {
}
public onRewardAdEarned() {
// Reward the user here
}
const handleEvents = ({value}) => {
__DEV__ && console.log(`Event: ${value}`);
switch (value) {
case 'onRewardAdEarned':
// Handle the event when the user has earned a reward
break;
case 'onRewardAdLoaded':
// Handle the event when the ad is loaded
break;
case 'onRewardAdOpened':
// Handle the event when the ad is opened
break;
case 'onRewardAdClosed':
// Handle the event when the ad is closed
break;
case 'onRewardAdFailedToLoad':
// Ad failed to load, let's try again after a delay
break;
case 'onRewardAdFailedToOpen':
// Ad failed to open, let's try again after a delay
break;
}
};
export const registerYodo1MAS = () => {
const eventEmitter = new NativeEventEmitter(Yodo1MASAds);
const eventListener = eventEmitter.addListener('adEvent', handleEvents);
// If needed, pass CCPA, COPPA, GDPR values in the initSDK method
Yodo1MASAds.initMasSdk(true, true, true);
return eventListener;
};
Impression-Level User Revenue
Starting in SDK version 4.13.2, you can access impression-level user revenue data on the client side. You can use this data to compare different sources and campaigns.
You can share impression-level ad revenue data with your mobile measurement partner of choice.
You can retrieve the revenue amount in all ad lifecycle callbacks. The following example shows how to do this within callback:
- Unity
- Java
- Kotlin
- Swift
- Objective-C
Yodo1U3dRewardAd.GetInstance().OnAdPayRevenueEvent += OnRewardAdPayRevenueEvent;
private void OnRewardAdPayRevenueEvent(Yodo1U3dRewardAd ad, Yodo1U3dAdValue adValue)
{
double revenue = adValue.Revenue;
string currency = adValue.Currency;
}
Yodo1MasRewardAd.getInstance().setAdRevenueListener(new Yodo1MasRewardAdRevenueListener() {
@Override
public void onRewardAdPayRevenue(Yodo1MasRewardAd ad, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
}
});
Yodo1MasRewardAd.getInstance().setAdRevenueListener { ad, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
}
Yodo1MasRewardAd.sharedInstance().adRevenueDelegate = self
func onRewardAdPayRevenue(_ ad: Yodo1MasRewardAd, _ adValue: Yodo1MasAdValue)
{
let revenue = adValue.revenue
let currency = adValue.currency
}
[Yodo1MasRewardAd sharedInstance].adRevenueDelegate = self;
#pragma mark - Yodo1MasRewardAdRevenueDelegate
- (void)onRewardAdPayRevenue:(Yodo1MasRewardAd *)ad withAdValue:(Yodo1MasAdValue *)adValue {
double revenue = adValue.revenue;
NSString *currency = adValue.currency;
}
You can also retrieve a precision evaluation for the revenue value, as shown in the following example:
- Unity
- Java
- Kotlin
- Swift
- Objective-C
string revenuePrecision = adValue.RevenuePrecision;
String revenuePrecision = adValue.getRevenuePrecision();
val revenuePrecision = adValue.revenuePrecision
let revenuePrecision = adValue.revenuePrecision
NSString *revenuePrecision = adValue.revenuePrecision;
This precision takes one of the following values:
"publisher_defined": the revenue amount is the price assigned by the publisher
"exact": the revenue amount is the result of a real-time auction
"estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
"": revenue and precision are not valid (for example, in test mode)
Video Tutorial
Best Practices
1. Preload
We recommend that you preload the rewarded video ad before showing it. This will ensure the ad is ready to be displayed when needed.
2. Placement
We recommend setting the placement name when you show the ad. This will help you track each placement's performance in the dashboard.
3. Handle Failures
If the ad fails to load, you should NOT try to reload immediately. Instead, it would be best if you waited a while before reloading the ad again. We recommend waiting at least 10 seconds before trying to fill the ad.