Skip to content

fix: reprepare reward ad after dismissal#16

Merged
2sem merged 1 commit intomainfrom
fix/reward-ad-reprepare
Mar 10, 2026
Merged

fix: reprepare reward ad after dismissal#16
2sem merged 1 commit intomainfrom
fix/reward-ad-reprepare

Conversation

@2sem
Copy link
Owner

@2sem 2sem commented Mar 10, 2026

Root Cause

reprepare(adObject:) guarded on intervals[unit] at the top, but reward units never set intervals — so it returned early and never reloaded the ad, causing the 'ad object has been used' error on the next show call.

Fix

Move the intervals guard inside the interstitial and opening branches only. Reward ads always reprepare unconditionally after dismissal.

🤖 Generated with Claude Code

Reward units never set intervals[], so the shared reprepare(adObject:)
guard was returning early and never reloading the ad. Move the interval
guard inside the interstitial/opening branches only, so reward ads
always reload after dismissal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@2sem 2sem merged commit fa73a5b into main Mar 10, 2026
2 checks passed
@github-actions
Copy link

🤖 Hi @2sem, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@2sem 2sem deleted the fix/reward-ad-reprepare branch March 10, 2026 08:11
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

## 📋 Review Summary

This PR correctly addresses the issue where rewarded ads were not being re-prepared after dismissal due to a top-level guard that checked for intervals (which rewarded ads do not have). The fix moves this check specifically into the interstitial and app open branches, ensuring rewarded ads can reload unconditionally as intended.

🔍 General Feedback

  • The fix is solid and solves the reported root cause.
  • The guard statements inside the ad-type branches for Interstitial and AppOpen ads are technically redundant, but they don't harm the current functionality.
  • For future development, it's worth considering a more modular approach to ad lifecycle management to avoid long if/else if chains.

Comment on lines +372 to 373
guard self.intervals[unit] != nil else { return }
self.reprepare(interstitialUnit: unit, isTesting: isTesting);

Choose a reason for hiding this comment

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

🟡 These `guard` statements are redundant and can be simplified.

Since the if/else if blocks already distinguish between ad types, and the reprepare methods for Interstitial and AppOpen ads are capable of handling nil intervals (by using defaults), these guards don't add functional value. Additionally, returning from the entire function here might be unexpected if more logic were to be added at the end of this method. This applies to both the Interstitial and AppOpen ad branches.

Suggested change
guard self.intervals[unit] != nil else { return }
self.reprepare(interstitialUnit: unit, isTesting: isTesting);
self.reprepare(interstitialUnit: unit, isTesting: isTesting);

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.

1 participant