Conversation
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>
|
🤖 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. |
There was a problem hiding this comment.
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
guardstatements 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 ifchains.
| guard self.intervals[unit] != nil else { return } | ||
| self.reprepare(interstitialUnit: unit, isTesting: isTesting); |
There was a problem hiding this comment.
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.
| guard self.intervals[unit] != nil else { return } | |
| self.reprepare(interstitialUnit: unit, isTesting: isTesting); | |
| self.reprepare(interstitialUnit: unit, isTesting: isTesting); |
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