Skip to content

Refresh on cold launch so notifications don't require pull-to-refresh#8

Open
useruserdev wants to merge 1 commit into
mainfrom
fix/cold-launch-refresh
Open

Refresh on cold launch so notifications don't require pull-to-refresh#8
useruserdev wants to merge 1 commit into
mainfrom
fix/cold-launch-refresh

Conversation

@useruserdev
Copy link
Copy Markdown
Owner

Problem

Notifications only appeared after a manual pull-to-refresh.

Cause

The launch refresh was wired only to onChange(of: scenePhase) for .active. On a cold launch the scene is already .active when the closure registers, so onChange never delivers that initial value — refreshAll() (which detects config changes and posts notifications) never ran at startup. It only ran on pull-to-refresh, on background→foreground returns, or via the rarely-scheduled BGAppRefreshTask.

Fix

Run the launch refresh from .task, which reliably runs once on first appearance. The onChange(.active) handler stays for genuine background→foreground returns; refreshAll()'s isRefreshing guard makes any overlap a no-op.

Verify on device

Fully close the app, change a subscription's configs server-side, then cold-launch — a notification should appear without pulling to refresh.

Note

This fixes the foreground/launch path. Guaranteed delivery while the app is fully closed still depends on BGAppRefreshTask, which iOS throttles heavily for sideloaded apps — an OS limitation, not a code bug.

The launch refresh was wired only to onChange(of: scenePhase) for .active.
scenePhase is already .active on cold launch, so onChange never fires for it
and refreshAll() (which detects changes and posts notifications) never ran at
startup. Updates only surfaced after a manual pull-to-refresh.

Trigger the refresh from .task, which reliably runs once on first appearance.
The onChange(.active) handler stays for background->foreground returns;
refreshAll()'s isRefreshing guard makes any overlap a no-op.
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