Implementing Reward Ads
How-to guide to implementing rewarded ads on Pley.
Requires Pley SDK 5.1.0 or later
Read more here.
Improvements ongoing
Rewarded Ads on Pley are powered by Google Adsense H5 Games - Google's flagship ad product for web gaming. It will improve over time, both in Pley's features and the quality of Google Ads. However, the UX is fully in Googles control.
We are actively looking to make improvements.
- Call
AdsKit.CanShowAdAsync
when the game displays a reward ad button.
If true, enable/show the button which initiates the reward ad. - Call
AdsKit.ShowRewardAd
.
If it returnsPleyResult.Ok
, grant the user the reward.
//Check if an ad is available. Returns true or false.
var (canShowAdResult, canShowRewardAd) = await AdsKit.CanShowRewardAdAsync();
//If canShowRewardAd == true, show the button to initiate a rewarded ad.
//Show the rewarded ad to the user. Returns PleyResult.Ok or PleyResult.AdkDismissed
var showRewardAdResult = await AdsKit.ShowRewardAdAsync();
//If showRewardAdResult == PleyResult.Ok, grant the user their reward.
It is very important that AdsKit.CanShowAdAsync
is called at one time before each call to AdsKit.ShowRewardAd
. This needs to be done to prepare the Google AdSense script and to check if your game can show an ad at this time.
Coded Example

Example code: The user gets a reward, and the game lets them watch an ad to double their reward.
private Button _doubleRewardButton;
void Awake()
{
_doubleRewardButton.onClick.AddListener(ShowDoubleRewardAd);
}
async void OpenRewardWindow()
{
// Triggers when the view above is initialized.
//
var (canShowAdResult, canShowRewardAd) = await AdsKit.CanShowRewardAdAsync();
// If we can not show the ad at this time disable/hide the doubleRewardAdButton
_doubleRewardButton.gameObject.SetActive(canShowRewardAd);
}
async void ShowDoubleRewardAd()
{
// Triggers when the "Double" button is pressed
//
var showRewardAdResult = await AdsKit.ShowRewardAdAsync();
if (showRewardAdResult == PleyResult.Ok)
{
// Give double rewards to the user.
return;
}
if (showRewardAdResult == PleyResult.AdkDismissed)
{
// The reward ad was dismissed/canceled by the user
}
else
{
// Reward ad failed to show
}
}
Finally, you must enable ads in the Game Manager.
And then the user will watch their ad, and get the reward!

Updated 30 days ago