Skip to content

fix(push): prevent lost notifications and missing images - #13

Merged
amarose merged 2 commits into
masterfrom
fix/notification-lost-on-destroy
Sep 28, 2026
Merged

amarose merged 2 commits into
masterfrom
fix/notification-lost-on-destroy

Conversation

@amarose

@amarose amarose commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Problem

When a push cold-starts the app, onMessageReceived returned before the notification
was built. Firebase then destroyed the messaging service and
PushNotificationDelegate.onDestroy() cancelled the in-flight image download:

  • since 3.2.1 the notification was dropped entirely (JobCancellationException, no notify()),
  • when the download failed first (network still blocked right after a cold start),
    the notification was posted without its image.

Fix

  • onMessageReceived waits on the messaging worker thread until the notification is posted;
    calls from the main thread keep the async path to avoid ANRs
  • onDestroy() no longer cancels in-flight work
  • image/icon downloads retry network errors with backoff within a shared 8 s budget;
    any other failure posts the notification without the image
  • CancellationException is no longer swallowed

No public API changes (apiCheck passes), so integrations forwarding messages through
FcmMessagingServiceDelegate get the fix by bumping the version.

Tests

PushNotificationDelegateTest: service destroyed mid download, transient network error,
non-retryable error. The first two fail without the fix and pass with it.

@amarose
amarose merged commit 7909cba into master Sep 28, 2026
3 checks passed
@amarose
amarose deleted the fix/notification-lost-on-destroy branch September 28, 2026 09:34
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