Implementing Reward Ads
How-to guide to implementing rewarded ads on Pley.
Pley supports rewarded ads on all platforms, and interstitial ads specifically on Crazy Games.
- Call
AdsKit.CanShowAdAsync
when the game displays a reward ad button.
If true, enable/show the button that 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!

Test-ads and real ads
When runnings games locally or in the Game Manager, all ads will be sandboxed. This means they are in "test" mode, and no real ads will be shown. It can be trusted for game-client implementation testing.
If you need to run real ads, you need to make a release track release and play there.
Updated 11 days ago