Auto-invalidate VC cache for verified rewards#6765
Merged
polmiro merged 5 commits intoMay 12, 2026
Conversation
peterporfy
approved these changes
May 11, 2026
ajpallares
reviewed
May 12, 2026
ajpallares
left a comment
Member
There was a problem hiding this comment.
Nice touch! Great QoL improvement, for sure. I have some suggestions for the implementation though
Invalidate RevenueCat virtual currencies cache automatically when reward verification returns a verified virtual currency so integrators get fresh data without manual invalidation. Update adapter docs and add tests covering when invalidation should and should not run.
Keep outcome mapping side-effect free and perform virtual currencies cache invalidation only in the main-actor reward verification callback path. Add callback-level tests to verify invalidation runs only for verified virtual currency outcomes.
Remove the extra PresentMapping test additions from this PR so the diff stays focused on virtual-currency cache invalidation behavior.
Limit virtual-currency cache invalidation testing to the reward callback boundary by injecting the invalidation closure into the handler, while keeping production behavior on the main actor. This avoids mutable global test hooks and clarifies test naming around createUserDidEarnRewardHandler semantics.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c91c537. Configure here.
c91c537 to
e55d7b8
Compare
Add explicit warning logging when virtual-currency cache invalidation is skipped because Purchases is not configured, matching existing reward verification observability patterns.
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.

Checklist
purchases-androidand hybridsMotivation
When reward verification returns a verified virtual-currency payload in the AdMob adapter, integrators currently need to remember to manually invalidate RevenueCat virtual currencies cache before fetching an updated balance. This is easy to miss and leads to stale balance reads.
Description
.verified(.virtualCurrency(...))..verified(.noReward),.verified(.unsupportedReward), or.failed.mapOutcomeside-effect free and perform invalidation in the main-actor callback dispatch path before deliveringrewardVerificationResult.PresentRewardVerificationTeststo verify invalidation behavior for each outcome type.PresentMappingTestsfocused on pure mapping behavior.Testing
swiftlint lint AdapterSDKs/RevenueCatAdMob/Sources/RevenueCatAdMob/RewardVerification/RewardVerification.swift AdapterSDKs/RevenueCatAdMob/Sources/RevenueCatAdMob/RewardVerification/RewardedAds+RewardVerification.swift AdapterSDKs/RevenueCatAdMob/Tests/RevenueCatAdMobTests/PresentMappingTests.swift AdapterSDKs/RevenueCatAdMob/Tests/RevenueCatAdMobTests/PresentRewardVerificationTests.swiftxcodebuild test -scheme "RevenueCatAdMob" -destination "platform=iOS Simulator,OS=18.4,name=iPhone 16"Note
Medium Risk
Adds a new automatic side effect (invalidating RevenueCat virtual-currency cache) on the reward-verification success path, which can affect integrators’ balance-refresh behavior and requires Purchases configuration checks.
Overview
Automatically invalidates RevenueCat’s virtual-currency cache when reward verification completes with
.verified(.virtualCurrency(...)), doing the side effect on the main-actor callback path before invokingrewardVerificationResult(and warning ifPurchasesisn’t configured).Updates the reward-verification handler API to support optional result callbacks and injectible invalidation for testing, and expands unit coverage to assert invalidation happens only for verified virtual-currency outcomes.
Documentation in the adapter README and integration sample is updated to clarify that cache invalidation is adapter-managed and apps only need to refetch balances when they need fresh UI.
Reviewed by Cursor Bugbot for commit 6ac5565. Bugbot is set up for automated code reviews on this repo. Configure here.