RewardedVideoAd.onClose
Listen for the rewarded video ad close event.
Parameters
function listener
The ad close event listener.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| isEnded | boolean | Whether this ad met the reward condition |
true can enter the game's reward flow, while false must not grant a reward. Closing alone is not a reward signal. Handle the reward result at most once per display.
Example
javascript
let rewardGranted = false;
rewardedVideoAd.onClose((res) => {
// Handle the reward result at most once per display
if (rewardGranted) {
return;
}
if (res.isEnded === true) {
// The reward condition is met; grant the reward
rewardGranted = true;
console.log('Reward condition met; grant the reward');
} else {
// The reward condition is not met; do not grant the reward
console.log('Reward condition not met; no reward');
}
});