diff --git a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java index 0b826a546..874a5fae6 100644 --- a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java +++ b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java @@ -83,8 +83,6 @@ public JSObject handleNotificationActionPerformed(Intent data, NotificationStora } String menuAction = data.getStringExtra(LocalNotificationManager.ACTION_INTENT_KEY); - dismissVisibleNotification(notificationId); - dataJson.put("actionId", menuAction); JSONObject request = null; try { @@ -93,6 +91,15 @@ public JSObject handleNotificationActionPerformed(Intent data, NotificationStora request = new JSObject(notificationJsonString); } } catch (JSONException e) {} + + // Only dismiss the tapped notification when autoCancel allows it; the + // builder already applies setAutoCancel(), but this explicit cancel used + // to run unconditionally, making `autoCancel: false` a no-op on tap. + boolean autoCancel = request == null || request.optBoolean("autoCancel", true); + if (autoCancel) { + dismissVisibleNotification(notificationId); + } + dataJson.put("notification", request); return dataJson; }