Rewarded Ads
Rewarded ads let users opt-in to watch a video ad in exchange for an in-game reward (extra lives, premium content, virtual currency, etc.).
Each ad format uses a Zone ID to identify the ad placement. Zone IDs are configured in the Empower dashboard.
Load the rewarded ad in advance and show it when the user chooses to watch. Grant the reward only on the Rewarded status.
Loading a Rewarded Ad
Load the ad in advance, after OnSdkReady:
EmpowerAds.LoadRewardedAd("YOUR_REWARDED_ZONE_ID");
Showing a Rewarded Ad
Show the ad when the user chooses to watch:
EmpowerAds.ShowRewarded("YOUR_REWARDED_ZONE_ID");
Listening to Rewarded Status
OnRewardedStatusChanged reports these statuses:
| Status | Reported when |
|---|---|
Initializing | The load started |
Ready | Ad is loaded and ready to display |
Shown | Ad is being displayed |
Rewarded | User earned the reward |
Skipped | The user dismissed the ad |
Closed | The ad is closed |
WillLeave | User clicked the ad (leaving the game) |
Failed | The zone could not load an ad and has given up |
Grant the reward on Rewarded and nowhere else. Skipped and Closed are reported when the ad is dismissed, whether or not the reward was earned.
Grant the reward on Rewarded and load the next ad on Closed:
using Empower.MobileAds;
using UnityEngine;
public class RewardedController : MonoBehaviour
{
private const string ZoneId = "YOUR_REWARDED_ZONE_ID";
private bool _isReady;
void OnEnable()
{
EmpowerAds.OnRewardedStatusChanged += HandleRewardedStatus;
}
void OnDisable()
{
EmpowerAds.OnRewardedStatusChanged -= HandleRewardedStatus;
}
// Call after OnSdkReady.
public void Load()
{
EmpowerAds.LoadRewardedAd(ZoneId);
}
// Wire this to your "watch an ad" button.
public void Show()
{
if (_isReady)
EmpowerAds.ShowRewarded(ZoneId);
}
private void HandleRewardedStatus(AdStatus status, string zoneId)
{
if (zoneId != ZoneId) return;
switch (status)
{
case AdStatus.Ready:
_isReady = true;
break;
case AdStatus.Failed:
_isReady = false;
break;
case AdStatus.Rewarded:
GrantReward();
break;
case AdStatus.Closed:
_isReady = false;
EmpowerAds.LoadRewardedAd(ZoneId);
break;
}
}
private void GrantReward()
{
// Give the player the reward.
}
}
On Android Closed always follows Skipped, so loading the next ad on Closed is enough. On iOS Closed may not follow, so handle Skipped there as well.