fix(push-notifications): show foreground notification image on Android - #2572
Open
Swiezu wants to merge 1 commit into
Open
fix(push-notifications): show foreground notification image on Android#2572Swiezu wants to merge 1 commit into
Swiezu wants to merge 1 commit into
Conversation
Swiezu
force-pushed
the
fix/android-foreground-notification-image
branch
from
July 28, 2026 22:05
6000235 to
d6824ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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 readsnotification.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 usesCommonNotificationBuilder/NotificationParams), so no new dependency is introduced.Tests or Reproductions
To reproduce the bug: send an FCM notification containing an
imageto 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
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).