Add android.noNotification for silent uploads - #28
Merged
Conversation
A consumer whose queue carries both user-visible media and housekeeping payloads had no way to keep the housekeeping ones out of the notification shade: every upload posts a progress notification, because posting one is how the worker enters foreground mode. noNotification skips the channel registration, the foreground promotion and the notify calls. Such an upload runs as an ordinary background worker, so the OS may defer or stop it — a path the worker already handles by letting WorkManager re-run it. Phrased as an opt-out because WorkManager persists the upload as JSON: a job enqueued by 8.0.0 and replayed by 8.1.0 has no such key, and an absent Gson Boolean is false, so it keeps its notification. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
elliottkember
marked this pull request as ready for review
August 12, 2026 05:51
elliottkember
requested review from
arnonate,
dhruv-dangi-openspace and
dmurphy5
and
a lite review from Copilot
and removed request for
Copilot
August 12, 2026 07:12
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.
Adds an Android option:
android: { noNotification: true }. The file uploads, and no progress notification appears.Why
Today every upload shows a notification and there is no way to turn it off. The notification is what puts the upload worker in foreground mode, so the worker always posts one.
That hurts an app that uploads two kinds of file: big ones the user is waiting for, and small ones they never asked about. The OpenSpace app has this problem. A field note syncs when the app opens, and the phone says "Uploading Captures…" when no capture is uploading.
The catch
A silent upload cannot use foreground mode, because foreground mode is what needs the notification. It runs as a normal background worker instead, so Android can delay it, or stop it and run it again later.
Nothing breaks when that happens. The library already treats a stop by Android as "still in flight" and lets WorkManager retry, so the app never sees a false failure. But it does mean you should only use this for small files. Anything that takes a while to upload should keep its notification. The option's doc comment, the README and the changelog all say so.
Why it is an opt-out and not
showNotificationWorkManager saves each upload as JSON, so an upload queued by 8.0.0 can run under 8.1.0 after an app update. That old JSON has no key for the new option, and Gson reads a missing boolean as
false. WithnoNotification,falsemeans "show the notification", so an old upload behaves as it did before. WithshowNotificationit would have gone silent by accident, and lost foreground mode with it. There is a test for this.The worker reads
upload.showsNotification, so the double negative stops at the data class.One more thing
Progress is still added up across all uploads, silent ones included. A visible notification's progress bar covers everything the device is uploading. That is unchanged.
Testing
All green locally:
yarn typecheck,yarn lint:ci(0 errors, plus 3 warnings that were already there in the example app),yarn test(7 tests), and./gradlew :react-native-background-upload:testDebugUnitTest. Three of the Kotlin tests are new and cover the option's default and its JSON round trip.I have not run this on a phone or an emulator, so nobody has watched a silent upload happen. Worth checking:
android: { noNotification: true }. There should be no notification, butprogressevents should still arrive, thencompleted.