From 43fb8f703627ba742f8d88ac152f77f6222006f0 Mon Sep 17 00:00:00 2001 From: Robin Kutesa Date: Mon, 1 Jun 2026 02:31:41 +0300 Subject: [PATCH] Fix stale notification count and add deeplink navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Evening check-in no longer embeds the urgent task count in the body — repeating notifications bake that value at schedule time so it always shows a stale number. Replaced with a generic prompt. didReceive now routes notification taps via ShortcutHandler: 'workout' deeplink → Workout tab, everything else → Today tab. Co-Authored-By: Kutesir --- KisaniCal/Managers/NotificationManager.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/KisaniCal/Managers/NotificationManager.swift b/KisaniCal/Managers/NotificationManager.swift index 7f3b66f..6fd0830 100644 --- a/KisaniCal/Managers/NotificationManager.swift +++ b/KisaniCal/Managers/NotificationManager.swift @@ -162,11 +162,12 @@ final class NotificationManager: NSObject, ObservableObject, @unchecked Sendable )) } - let count = snapshot.filter { !$0.isComplete && $0.quadrant == .urgent }.count - guard count > 0 else { return } + // No count in body — repeating notifications bake in the value + // at schedule time and go stale until the app is next opened. + guard snapshot.contains(where: { !$0.isComplete && $0.quadrant == .urgent }) else { return } let ec = UNMutableNotificationContent() ec.title = "Evening check-in" - ec.body = "\(count) urgent task\(count == 1 ? "" : "s") still open." + ec.body = "You still have urgent tasks open — tap to review." ec.sound = .default ec.userInfo = ["deeplink": "tasks"] var eComps = DateComponents(); eComps.hour = 19; eComps.minute = 30 @@ -204,6 +205,15 @@ extension NotificationManager: UNUserNotificationCenterDelegate { didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void ) { + let deeplink = response.notification.request.content.userInfo["deeplink"] as? String + Task { @MainActor in + switch deeplink { + case "workout": + ShortcutHandler.shared.handle(QuickAction.workout.rawValue) + default: + ShortcutHandler.shared.handle(QuickAction.today.rawValue) + } + } completionHandler() } }