Repository navigation
[SDK-871] Retry the push notification image once on API 31+ when the download fails - #1110
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jena-chakour
self-requested a review
November 20, 2026 21:44
jena-chakour
left a comment
Contributor
There was a problem hiding this comment.
@franco-zalamena-iterable would it be good to add a timeout for the first attempt? otherwise fwiw LGTM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
Last commit added it, i was leaving it out to a separate ticket to try to make this one more concise but i think we can add it in this same PR maybe makes it more clear |
konrad-journi
approved these changes
Nov 24, 2026
konrad-journi
left a comment
There was a problem hiding this comment.
Tested this branch and can confirm the fix works
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.
📝 Summary
On API 31+, if the push image fails to download, the SDK retries it once when there is network and adds it to the notification already showing. Every image download also gives up after 15s now, so a stalled download doesn't hold the notification back
🎟️ Jira Ticket: SDK-871
📖 Description
Thanks @konrad-journi for the report and for proposing the first fix
Our backend never sets an FCM priority, so Android pushes arrive as normal priority. When the app is in the rare or restricted standby bucket, in Doze or in battery saver, its network is blocked while the image worker runs, so the download fails with UnknownHostException and the notification shows text only. Data Saver on a metered network blocks it at any priority
The proposed one liner adds a CONNECTED constraint to the first request. We didn't take it as is because it holds the notification itself until the constraint is met, which under Data Saver can be indefinitely. It also only helps on API 31+, where expedited jobs with a network constraint get past the standby network block, and it broke an existing test
This PR keeps the first request unconstrained, the notification still posts right away and is text only if the image fails. On API 31+, if the download fails with an IOException and the push has a messageId, we enqueue one follow up job. It is unique per notification, expedited and has a CONNECTED constraint
The follow up waits until at least 3s have passed since the first failure, because Android caches a failed DNS lookup for 2s. Then it downloads the image with 15s timeouts and re-posts the same notification with the image. It uses setOnlyAlertOnce and the original
when, so there is no second alert and the notification doesn't jump to the topIt does nothing if the notification was dismissed, belongs to a different push, is older than 24h, the worker was stopped or the image fails again. There is no retry loop
The first image download had no timeout, so a stalled connection held back the notification itself. On an emulator it once hung for 134s. Every image download now gives up after 15s without connecting or without receiving data. That covers the first attempt, the follow up and apps that build notifications themselves through
IterableNotificationHelper.createNotificationThe image is still decoded as it streams, but a read error the decoder would swallow, including a timeout, now counts as a failed download. So a stall partway through the image posts the notification text only and on API 31+ the follow up adds the image, instead of a cut off image being posted. A stall only in the bytes after a complete image still shows the image. An image that downloads but can't be decoded still posts text only, with no retry. Below API 31 the timeout applies too, there is just no follow up
Known gaps: the notification's timestamp is set before the image download starts, so after a stalled download it reads up to about 15s earlier than when the notification appeared. This is already the case on master and it's only cosmetic
🧪 How to test?
Unit tests cover:
whenManual tests on a Medium Phone emulator, API 36, with real FCM pushes at normal priority unless noted:
With the timeout, on the same emulator:
🧾 Changelog
Added under Unreleased
🐞 Github Issues solved
Issue: #1109
🤖 Generated with Claude Code