Skip to content

Require rewardVerificationResult callback#6762

Merged
polmiro merged 2 commits into
mainfrom
reward-verification-callback-follow-up
May 12, 2026
Merged

Require rewardVerificationResult callback#6762
polmiro merged 2 commits into
mainfrom
reward-verification-callback-follow-up

Conversation

@polmiro

@polmiro polmiro commented May 11, 2026

Copy link
Copy Markdown
Member

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

This change tightens the AdMob reward-verification API contract so integrations handle the resolved verification outcome by default, not only verification start. It improves correctness, aligns with stricter cross-platform direction, and matches AdMob rewarded-ad semantics where presentation requires a reward handler (OnUserEarnedRewardListener on Android / userDidEarnRewardHandler on iOS).

Description

Why

  • Enforce that reward-verification flows consume the final resolved outcome.
  • Keep flexibility for callers who intentionally ignore results ({ _ in }).
  • Align adapter API with underlying platform-level rewarded-ad contracts.

What changed

  • Breaking API update in RewardedAds+RewardVerification:
    • rewardVerificationStarted remains optional.
    • rewardVerificationResult is now required (non-optional, no default) for:
      • GoogleMobileAds.RewardedAd.present(...) (with and without placement)
      • GoogleMobileAds.RewardedInterstitialAd.present(...) (with and without placement)
  • Internal handler update:
    • createUserDidEarnRewardHandler(...) now requires rewardVerificationResult.
    • Removed the optional callback guard path.
    • Kept missing-state behavior (warn + assert and .failed) and existing dispatch semantics.
  • Tests:
    • Updated APISurfaceTests to reflect required callback signatures.
    • Removed nil callback usage from PresentRewardVerificationTests.
    • Preserved coverage for verified/failed outcomes, started-before-result ordering, and optional rewardVerificationStarted.

Migration impact

Before:

rewardedAd?.present(from: viewController)

After:

rewardedAd?.present(
    from: viewController,
    rewardVerificationResult: { result in
        // handle verified/failed result, or intentionally ignore with { _ in }
    }
)

Note

Medium Risk
Breaking API change to rewarded-ad present methods: callers must now provide a rewardVerificationResult handler, which could require downstream migration and affects runtime behavior if omitted previously.

Overview
Tightens the reward-verification API contract for AdMob rewarded ads by making rewardVerificationResult a required, non-optional callback for RewardedAd and RewardedInterstitialAd present(...) (with and without placement).

Internally, createUserDidEarnRewardHandler(...) now always expects a result handler, removes the nil-guard path, and consistently reports .failed when reward verification state is missing (while still warning/asserting). Tests are updated to reflect the new required callback signatures and remove the “nil result callback” scenario.

Reviewed by Cursor Bugbot for commit 966b963. Bugbot is set up for automated code reviews on this repo. Configure here.

@polmiro polmiro added the pr:feat A new feature label May 11, 2026
@polmiro polmiro force-pushed the reward-verification-callback-follow-up branch from 717f1c1 to 0d6aaf4 Compare May 11, 2026 13:53
@polmiro polmiro changed the title breaking(admob): require rewardVerificationResult callback Require rewardVerificationResult callback May 11, 2026
Enforce the rewarded-ad verification contract by making rewardVerificationResult mandatory in the AdMob verification present APIs while keeping rewardVerificationStarted optional. This aligns with platform-level AdMob reward handler requirements and prevents flows that start verification without consuming the resolved outcome.
@polmiro polmiro force-pushed the reward-verification-callback-follow-up branch from 0d6aaf4 to 3e49ceb Compare May 11, 2026 13:54
@polmiro polmiro changed the title Require rewardVerificationResult callback breaking(admob): require rewardVerificationResult callback May 11, 2026
@polmiro polmiro requested a review from ajpallares May 11, 2026 13:55
@polmiro polmiro marked this pull request as ready for review May 11, 2026 13:55
@polmiro polmiro requested a review from a team as a code owner May 11, 2026 13:55
@polmiro polmiro requested a review from peterporfy May 11, 2026 13:56
@polmiro polmiro changed the title breaking(admob): require rewardVerificationResult callback Require rewardVerificationResult callback May 11, 2026
@polmiro polmiro added pr:admob pr:other and removed pr:feat A new feature labels May 11, 2026
Update the rewarded verification API surface assertions to expect an escaping result callback, matching the tightened present signatures and preventing CI compile failures in RevenueCatAdMobTests.

@peterporfy peterporfy 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.

Looks good to me!

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great catch! I think this makes sense

@polmiro polmiro merged commit d67a4d6 into main May 12, 2026
42 checks passed
@polmiro polmiro deleted the reward-verification-callback-follow-up branch May 12, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants