Skip to content

fix(push-notifications): show foreground notification image on Android - #2572

Open
Swiezu wants to merge 1 commit into
ionic-team:mainfrom
Swiezu:fix/android-foreground-notification-image
Open

fix(push-notifications): show foreground notification image on Android#2572
Swiezu wants to merge 1 commit into
ionic-team:mainfrom
Swiezu:fix/android-foreground-notification-image

Conversation

@Swiezu

@Swiezu Swiezu commented Jul 28, 2026

Copy link
Copy Markdown

Description

When a notification message carrying an image arrives while the app is in the foreground on Android, the plugin now downloads the image and displays it as a BigPictureStyle (also set as the large icon), matching how the same push renders when it arrives in the background. The download runs off the main thread with a 5s timeout; on failure or timeout the notification is still posted without the image.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

Fixes #1830. On Android, foreground notifications are built and posted by the plugin itself via CommonNotificationBuilder.createNotificationInfo(...) + notificationManager.notify(...). That path never reads notification.getImageUrl(), so images and icons that show on background notifications are missing when the same push arrives in the foreground. Background notifications work only because FCM's own service downloads the image before posting.

This change replicates that download for the foreground path, reusing the same internal FCM helper (com.google.firebase.messaging.ImageDownload) the code already depends on (it already uses CommonNotificationBuilder / NotificationParams), so no new dependency is introduced.

Tests or Reproductions

To reproduce the bug: send an FCM notification containing an image to a device with the app in the foreground — the image is missing, while the same push shows it when the app is backgrounded.

Running in a production Capacitor 8 app: with this change a foregrounded push with an image now renders the picture identically to the background case. Verified the download runs off the main thread and falls back to a text-only notification on failure/timeout.

Screenshots / Media

Platforms Affected

  • Android
  • iOS
  • Web

Notes / Comments

Foreground notifications are posted by the plugin, background ones by FCM — this aligns the two so they look the same. iOS is unaffected (rich media there is handled by the notification service extension).

@Swiezu
Swiezu force-pushed the fix/android-foreground-notification-image branch from 6000235 to d6824ad Compare July 28, 2026 22:05
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.

Issue with images and icons not being displayed in push messages received while in the foreground on Android devices.

1 participant