Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ios/CCC/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,13 @@ struct Application: App {
}

private func onScenePhaseChange(phase: ScenePhase) {
logger.i(message: { "Application onChange scenePhase \(phase)" })
logger.i(message: { "Application onChange scenePhase ground \(phase)" })
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
logger.i(message: { "Application onChange scenePhase ground \(phase)" })
logger.i(message: { "Application onChange scenePhase \(phase)" })

Copilot uses AI. Check for mistakes.

switch phase {
case .active:
observable.event.onAppForeground()
case .inactive:
// only when come from active, since it visits inactive while coming from background
if scenePhase == .active {
observable.event.onAppBackground()
}
observable.event.onAppBackground()
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
case .background:
scheduleAppRefresh()
@unknown default:
Expand Down
Loading