Fix stale notification count and add deeplink navigation

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 <tqwyy79vzn@privaterelay.appleid.com>
This commit is contained in:
Robin Kutesa
2026-06-01 02:31:41 +03:00
parent a49d5fea35
commit 43fb8f7036

View File

@@ -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()
}
}