feat(Android): add notification action buttons - #271
Open
Dre-Van-den-Hooff-Codifly wants to merge 1 commit into
Open
feat(Android): add notification action buttons#271Dre-Van-den-Hooff-Codifly wants to merge 1 commit into
Dre-Van-den-Hooff-Codifly wants to merge 1 commit into
Conversation
Adds an `actions` option that renders buttons on the foreground service notification, and emits `notificationAction` with the pressed button's id. Closes Rapsssito#60. - `actions: [{id, title}]` is added to the notification builder, each button broadcasting an explicit intent carrying its own id. - The broadcast receiver is registered at runtime rather than in the manifest: the notification only exists while the service, and therefore the process, is alive, so there is never a press with no receiver to take it. It is unregistered in `invalidate()` so a JS reload does not leak one. - Each button gets its own PendingIntent request code; sharing one makes every button deliver whichever intent was registered first. - `notificationAction` is re-emitted through the existing EventEmitter, so it is consumed the same way as `expiration`. - The subscription is Android-only. `RNBackgroundActions` declares `expiration` as its only supported event on iOS, so subscribing there makes RCTEventEmitter log `\`notificationAction\` is not a supported event type` on every launch of a debug build. - The platform is set in `jest.setup.js` rather than in the test file: the server subscribes when it is constructed, which is when a test file imports it — before any assignment inside that file has run. - `_normalizeOptions` passes `actions` through. It is applied on every `updateNotification()` too, so without this the buttons would disappear on the first progress update. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Dre-Van-den-Hooff-Codifly
force-pushed
the
feat/notification-actions
branch
from
August 13, 2026 12:28
76e4f3e to
b985446
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.
Adds an optional
actionsoption that renders buttons on the foreground service notification, and emitsnotificationActionwhen one is pressed.Closes #60.
Usage
Passing a new
actionsarray toupdateNotification()swaps the buttons, so atask can show
pausewhile running andresumewhile paused.Notes on the implementation
notification only exists while the service — and therefore the process — is
alive, so there is never a press with no receiver to take it. It also avoids
an exported manifest receiver. Unregistered in
invalidate()so a JS reloaddoesn't leak one.
PendingIntentrequest code. Sharing one makesevery button deliver whichever intent was registered first.
_normalizeOptionspassesactionsthrough. It runs on everyupdateNotification()too, so without this the buttons would disappear on thefirst progress update. Covered by a regression test.
notificationActionis re-emitted through the existingEventEmitter, soit's consumed exactly like
expiration.actionsis optional and Android-only; no behaviour changes when it's absent,and no iOS changes.
Testing
yarn cipasses: 15 tests, 100% coverage onindex.js. Four new cases —actionspassed through on start, kept acrossupdateNotification(),undefined when not supplied, and the event re-emission.
against RN 0.85 / AGP, and the full flow (buttons rendering, presses driving
pause/resume/cancel through the foreground service) is running in a shipped
release build on a physical device.