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:
@@ -162,11 +162,12 @@ final class NotificationManager: NSObject, ObservableObject, @unchecked Sendable
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
let count = snapshot.filter { !$0.isComplete && $0.quadrant == .urgent }.count
|
// No count in body — repeating notifications bake in the value
|
||||||
guard count > 0 else { return }
|
// 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()
|
let ec = UNMutableNotificationContent()
|
||||||
ec.title = "Evening check-in"
|
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.sound = .default
|
||||||
ec.userInfo = ["deeplink": "tasks"]
|
ec.userInfo = ["deeplink": "tasks"]
|
||||||
var eComps = DateComponents(); eComps.hour = 19; eComps.minute = 30
|
var eComps = DateComponents(); eComps.hour = 19; eComps.minute = 30
|
||||||
@@ -204,6 +205,15 @@ extension NotificationManager: UNUserNotificationCenterDelegate {
|
|||||||
didReceive response: UNNotificationResponse,
|
didReceive response: UNNotificationResponse,
|
||||||
withCompletionHandler completionHandler: @escaping () -> Void
|
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()
|
completionHandler()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user