The rewarded ad grants the reward when the ad is dismissed, not when the user actually earns it. Look at showRewardAd:
rewardedAd.show(context, rewardItem -> {}); // the earned-reward callback is EMPTY
rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
@Override
public void onAdDismissedFullScreenContent() {
int reward = 50 + new Random().nextInt(201);
user.sendEvent(SocketEvents.REWARDED, user.getUsername(), reward); // reward sent on DISMISS
}
...
});
The AdMob API gives you an OnUserEarnedRewardListener (the rewardItem -> {} lambda in .show()), and that's the callback that fires only when the user actually watches enough of the ad to earn the reward. Here that lambda is empty, and the reward is instead sent from onAdDismissedFullScreenContent, which fires whenever the ad closes, including when the user closes it early without watching.
So a user can open a rewarded ad, immediately close it, and still get the reward request sent. The server caps and rate-limits the ad reward (good), but a user still farms free coins per ad view without watching anything, up to the rate limit.
The reward should be sent from the OnUserEarnedRewardListener, not from onAdDismissed.
Also minor: the FullScreenContentCallback is set after .show() is already called, which is a bit racy for catching early events. Worth setting it before show.
File: android/src/com/focus/kingdom/platform/AdManager.java, showRewardAd, around line 123-143.
The rewarded ad grants the reward when the ad is dismissed, not when the user actually earns it. Look at showRewardAd:
The AdMob API gives you an OnUserEarnedRewardListener (the
rewardItem -> {}lambda in.show()), and that's the callback that fires only when the user actually watches enough of the ad to earn the reward. Here that lambda is empty, and the reward is instead sent from onAdDismissedFullScreenContent, which fires whenever the ad closes, including when the user closes it early without watching.So a user can open a rewarded ad, immediately close it, and still get the reward request sent. The server caps and rate-limits the ad reward (good), but a user still farms free coins per ad view without watching anything, up to the rate limit.
The reward should be sent from the OnUserEarnedRewardListener, not from onAdDismissed.
Also minor: the FullScreenContentCallback is set after
.show()is already called, which is a bit racy for catching early events. Worth setting it before show.File:
android/src/com/focus/kingdom/platform/AdManager.java, showRewardAd, around line 123-143.