fix(local-notifications): honor autoCancel when a notification is tapped#2568
Open
begezavr2 wants to merge 1 commit into
Open
fix(local-notifications): honor autoCancel when a notification is tapped#2568begezavr2 wants to merge 1 commit into
begezavr2 wants to merge 1 commit into
Conversation
handleNotificationActionPerformed dismissed the tapped notification unconditionally, so `autoCancel: false` had no effect on tap even though the builder sets setAutoCancel() from it. Read autoCancel from the notification payload carried in the intent (default true) and skip the explicit dismissal when the caller opted out. Fixes the behavior reported in ionic-team#1384.
begezavr2
force-pushed
the
fix/local-notifications-autocancel-tap
branch
from
July 20, 2026 16:47
088715d to
b938157
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.
Closes #2567
What
On Android,
handleNotificationActionPerformeddismissed the tapped notification unconditionally viadismissVisibleNotification(notificationId), which madeautoCancel: falsea no-op on the tap path — the notification disappeared from the shade on every tap regardless of the flag (the builder'ssetAutoCancel(false)never got a chance to matter, since the plugin issues its own explicitNotificationManager.cancel()).How
Read
autoCancelfrom the notification payload the tap intent already carries (NOTIFICATION_OBJ_INTENT_KEY) and only calldismissVisibleNotificationwhen it istrue. The default staystrue(also when the payload is absent or unparseable), so behavior is unchanged for every caller that didn't explicitly setautoCancel: false.Testing
Manually on a physical device (Android 14, Capacitor 8.4.2):
schedule({ notifications: [{ id, title, body, autoCancel: false }] })→ tap → app opens, notification stays in the shade.autoCanceland withautoCancel: true→ tap → notification is dismissed (unchanged behavior).idstill replaces the delivered notification in place.Context
Fixes the behavior reported in #1384 (closed by the bot for lack of reproduction, locked; the code path is unchanged since then).