Bug Report
Plugin(s)
@capacitor/local-notifications 8.2.1 (bug present on main as well)
Capacitor Version
Latest Dependencies:
@capacitor/cli: 8.4.2
@capacitor/core: 8.4.2
@capacitor/android: 8.4.2
Installed Dependencies:
@capacitor/cli: 8.4.2
@capacitor/core: 8.4.2
@capacitor/android: 8.4.2
Platform(s)
Current Behavior
Tapping a notification always removes it from the shade, even when it was scheduled with autoCancel: false.
The builder does apply the flag (LocalNotificationManager.buildNotification → .setAutoCancel(localNotification.isAutoCancel())), but handleNotificationActionPerformed then calls dismissVisibleNotification(notificationId) unconditionally:
https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L86
That explicit NotificationManager.cancel() runs on every tap, so the autoCancel value never matters on the tap path.
Expected Behavior
With autoCancel: false, tapping the notification opens the app and the notification stays in the shade (standard Android setAutoCancel(false) semantics). This matters for "live status" notifications, e.g. a running-stopwatch readout that should persist until the user stops the timer in the app.
Code Reproduction
import { LocalNotifications } from '@capacitor/local-notifications';
await LocalNotifications.requestPermissions();
await LocalNotifications.schedule({
notifications: [
{
id: 1,
title: 'Timer',
body: 'Running',
autoCancel: false,
},
],
});
// Tap the delivered notification → it is removed from the shade,
// although autoCancel is false.
Other Technical Details
Previously reported in #1384 (Capacitor 4), which was closed by the bot for lack of a code reproduction and locked; the code path is unchanged.
Additional Context
Fix PR: #2568 — reads autoCancel from the notification payload already carried in the tap intent (NOTIFICATION_OBJ_INTENT_KEY, default true, so existing behavior is preserved for everyone who didn't opt out) and skips the explicit dismissal when the caller set autoCancel: false.
Bug Report
Plugin(s)
@capacitor/local-notifications8.2.1 (bug present onmainas well)Capacitor Version
Platform(s)
Current Behavior
Tapping a notification always removes it from the shade, even when it was scheduled with
autoCancel: false.The builder does apply the flag (
LocalNotificationManager.buildNotification→.setAutoCancel(localNotification.isAutoCancel())), buthandleNotificationActionPerformedthen callsdismissVisibleNotification(notificationId)unconditionally:https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L86
That explicit
NotificationManager.cancel()runs on every tap, so theautoCancelvalue never matters on the tap path.Expected Behavior
With
autoCancel: false, tapping the notification opens the app and the notification stays in the shade (standard AndroidsetAutoCancel(false)semantics). This matters for "live status" notifications, e.g. a running-stopwatch readout that should persist until the user stops the timer in the app.Code Reproduction
Other Technical Details
Previously reported in #1384 (Capacitor 4), which was closed by the bot for lack of a code reproduction and locked; the code path is unchanged.
Additional Context
Fix PR: #2568 — reads
autoCancelfrom the notification payload already carried in the tap intent (NOTIFICATION_OBJ_INTENT_KEY, defaulttrue, so existing behavior is preserved for everyone who didn't opt out) and skips the explicit dismissal when the caller setautoCancel: false.