[Oztechan/CCC#4572] Fix iOS too often interstitial Ad issue#4573
[Oztechan/CCC#4572] Fix iOS too often interstitial Ad issue#4573mustafaozhan merged 1 commit intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix an issue where interstitial ads are shown too frequently on iOS by modifying the scene phase change handling logic in the Application.swift file. However, the changes appear to have unintended consequences.
Key changes:
- Modified the log message in onScenePhaseChange (contains a typo)
- Removed the conditional check that prevented onAppBackground() from being called during app foregrounding
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| private func onScenePhaseChange(phase: ScenePhase) { | ||
| logger.i(message: { "Application onChange scenePhase \(phase)" }) | ||
| logger.i(message: { "Application onChange scenePhase ground \(phase)" }) |
There was a problem hiding this comment.
The log message contains what appears to be a typo: "scenePhase ground" should likely be just "scenePhase" to match the original intent and maintain consistency with other log messages.
| logger.i(message: { "Application onChange scenePhase ground \(phase)" }) | |
| logger.i(message: { "Application onChange scenePhase \(phase)" }) |
| if scenePhase == .active { | ||
| observable.event.onAppBackground() | ||
| } | ||
| observable.event.onAppBackground() |
There was a problem hiding this comment.
Removing the conditional check causes onAppBackground() to be called during BOTH backgrounding AND foregrounding transitions, which contradicts the PR's goal of fixing "too often interstitial Ad issue."
iOS scene phase lifecycle:
- When backgrounding: active → inactive → background
- When foregrounding: background → inactive → active
The old code correctly called onAppBackground() only during backgrounding (active → inactive). The new code calls it during foregrounding too (background → inactive), which will cancel the ad job immediately before onAppForeground() restarts it. This creates unnecessary churn and doesn't align with the Android implementation (which only calls onAppBackground in onPause).
The original conditional logic was correct. If the issue is that ads are showing too frequently, the fix should likely be in the ad timer configuration (interstitialAdPeriod/interstitialAdInitialDelay in MainViewModel.kt) rather than changing when onAppBackground() is called.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4573 +/- ##
========================================
Coverage 55.63% 55.63%
========================================
Files 169 169
Lines 3013 3013
Branches 445 445
========================================
Hits 1676 1676
Misses 1312 1312
Partials 25 25 🚀 New features to boost your workflow:
|
|



Resolves #4572