Skip to content

Rewarded: grant the reward only when the controller reports it - #1029

Merged
mdanylov-sigma merged 1 commit into
masterfrom
claude/prebid-mobile-android-1026-26bb39
Oct 7, 2026
Merged

mdanylov-sigma merged 1 commit into
masterfrom
claude/prebid-mobile-android-1026-26bb39

Conversation

@mdanylov-sigma

Copy link
Copy Markdown
Collaborator

Closes #1026

Problem

BaseInterstitialAdUnit granted the reward on every close: its controller listener called notifyUserReward() from onInterstitialClosed(). A third-party plugin renderer owns its own reward rules and reports the reward through InterstitialControllerListener.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 triggered RewardedAdUnitListener.onUserEarnedReward.

Fix

onInterstitialClosed() no longer grants the reward. Only onUserEarnedReward() does, and its Javadoc now says so.

Prebid's own renderer is unchanged. InterstitialController.onAdClosed already calls listener.onUserEarnedReward() after onInterstitialClosed() when the RewardManager has not rewarded the user yet. The close reward still fires, still after onAdClosed. 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:

  • AdMob and MAX rewarded adapters: their onInterstitialClosed() never grants a reward. Plugin controllers used through mediation already follow this rule.
  • iOS: BaseInterstitialAdUnit.interstitialControllerDidCloseAd only dismisses. The reward comes only from the controller's trackUserReward.

Why not the opt-in flag proposed in the issue

The issue suggests a default method on PrebidMobileInterstitialControllerInterface that a plugin overrides to opt out of the close reward. I chose not to add it:

  • With a default of false, every existing plugin keeps the bug until it ships an update.
  • It adds public API surface that iOS doesn't need, since iOS never had the fallback.
  • The fallback was never needed for 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 through RewardedAdUnit. 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

  • RewardedAdUnitTest
    • A controller that closes without reporting a reward grants none. This test fails on master (NeverWantedButInvoked).
    • A reported reward is granted once, before close.
    • A real InterstitialController wired to the ad unit still grants the reward right after onAdClosed.
  • 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() inside onAdClosed with Prebid's renderer gets an NPE at InterstitialController.java:104. destroy() nulls the controller's listener and clears the RewardManager, so the close fallback then calls onUserEarnedReward() 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

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>

@YuriyVelichkoPI YuriyVelichkoPI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mdanylov-sigma
mdanylov-sigma merged commit 0d15524 into master Oct 7, 2026
6 checks passed
@mdanylov-sigma
mdanylov-sigma deleted the claude/prebid-mobile-android-1026-26bb39 branch October 7, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewarded: closing a plugin-rendered ad early still grants the reward

2 participants