Skip to content

fix(local-notifications): honor autoCancel when a notification is tapped#2568

Open
begezavr2 wants to merge 1 commit into
ionic-team:mainfrom
begezavr2:fix/local-notifications-autocancel-tap
Open

fix(local-notifications): honor autoCancel when a notification is tapped#2568
begezavr2 wants to merge 1 commit into
ionic-team:mainfrom
begezavr2:fix/local-notifications-autocancel-tap

Conversation

@begezavr2

Copy link
Copy Markdown

Closes #2567

What

On Android, handleNotificationActionPerformed dismissed the tapped notification unconditionally via dismissVisibleNotification(notificationId), which made autoCancel: false a no-op on the tap path — the notification disappeared from the shade on every tap regardless of the flag (the builder's setAutoCancel(false) never got a chance to matter, since the plugin issues its own explicit NotificationManager.cancel()).

How

Read autoCancel from the notification payload the tap intent already carries (NOTIFICATION_OBJ_INTENT_KEY) and only call dismissVisibleNotification when it is true. The default stays true (also when the payload is absent or unparseable), so behavior is unchanged for every caller that didn't explicitly set autoCancel: 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.
  • Same without autoCancel and with autoCancel: true → tap → notification is dismissed (unchanged behavior).
  • Re-scheduling with the same id still 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).

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
begezavr2 force-pushed the fix/local-notifications-autocancel-tap branch from 088715d to b938157 Compare July 20, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: local-notifications (Android): autoCancel: false is ignored when the notification is tapped

1 participant