Repository navigation
Rewarded: grant the reward only when the controller reports it - #1029
Merged
Merged
Conversation
BaseInterstitialAdUnit granted the reward whenever the interstitial controller reported a close. That overrode third-party plugin renderers, which own their reward rules: a user who closed a plugin-rendered rewarded ad early still got onUserEarnedReward. Closing no longer grants the reward. The controller reports it through InterstitialControllerListener.onUserEarnedReward(). Prebid's own InterstitialController already calls it on close when the user was not rewarded yet, so the built-in renderer behaves as before. This matches the AdMob and MAX adapters and the iOS SDK, which never reward on close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1026
Problem
BaseInterstitialAdUnitgranted the reward on every close: its controller listener callednotifyUserReward()fromonInterstitialClosed(). A third-party plugin renderer owns its own reward rules and reports the reward throughInterstitialControllerListener.onUserEarnedReward(). The close fallback overrode that, so a user who closed a plugin-rendered rewarded ad early (for example, Chartboost before the reward duration) still triggeredRewardedAdUnitListener.onUserEarnedReward.Fix
onInterstitialClosed()no longer grants the reward. OnlyonUserEarnedReward()does, and its Javadoc now says so.Prebid's own renderer is unchanged.
InterstitialController.onAdClosedalready callslistener.onUserEarnedReward()afteronInterstitialClosed()when theRewardManagerhas not rewarded the user yet. The close reward still fires, still afteronAdClosed. The ad unit's own fallback was a duplicate of that.This also makes the standalone API consistent with code paths that already work this way:
onInterstitialClosed()never grants a reward. Plugin controllers used through mediation already follow this rule.BaseInterstitialAdUnit.interstitialControllerDidCloseAdonly dismisses. The reward comes only from the controller'strackUserReward.Why not the opt-in flag proposed in the issue
The issue suggests a default method on
PrebidMobileInterstitialControllerInterfacethat a plugin overrides to opt out of the close reward. I chose not to add it:false, every existing plugin keeps the bug until it ships an update.PrebidRenderer, as explained above.Behavior change for plugin authors: a third-party plugin that supports rewarded ads but never calls
onUserEarnedReward()will no longer grant a reward throughRewardedAdUnit. Through the AdMob/MAX adapters and on iOS, such a plugin already granted none. If reviewers would rather keep the old behavior for these plugins, the opt-in flag can be added on top of this change.Tests
RewardedAdUnitTestNeverWantedButInvoked).InterstitialControllerwired to the ad unit still grants the reward right afteronAdClosed.InterstitialControllerTest: covers the built-in close fallback, both before and after the reward.:PrebidMobile-core:testReleaseUnitTest: 1441 tests pass.Not in this PR
A pre-existing crash: a publisher who calls
rewardedAdUnit.destroy()insideonAdClosedwith Prebid's renderer gets an NPE atInterstitialController.java:104.destroy()nulls the controller's listener and clears theRewardManager, so the close fallback then callsonUserEarnedReward()on a null listener. I reproduced it on master without this change, and it is unaffected by it. I'll handle it separately.🤖 Generated with Claude Code