From d8138a4fc07ddc910551ab9044ac87a9ca07f3b7 Mon Sep 17 00:00:00 2001 From: Andrew Blakeslee Moore Date: Mon, 6 Jul 2026 12:53:50 -0700 Subject: [PATCH] Adjust Push Notification Logic Nucleic-Session: 0F065CD6-20FE-4941-ACF5-C57A4572A5A3 Co-authored-by: Nucleic --- NucleicRemote/NucleicRemote/Notifications.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/NucleicRemote/NucleicRemote/Notifications.swift b/NucleicRemote/NucleicRemote/Notifications.swift index c6c3cb6..228a539 100644 --- a/NucleicRemote/NucleicRemote/Notifications.swift +++ b/NucleicRemote/NucleicRemote/Notifications.swift @@ -108,6 +108,23 @@ final class NotificationRouter: NSObject { center.removePendingNotificationRequests(withIdentifiers: [identifier]) } + /// Recall the shared "waiting for your approval" attention notification once nothing is pending + /// anywhere. This is the remote wake tickle (delivered under `approvalTickleIdentifier`) that a + /// prior push left on the lock screen — the counterpart to the per-approval `withdrawApproval`. + /// Arrives two ways: the relay's silent `clear` push (phone was away), or the store's own + /// reconcile when a live socket sees the last approval resolve. Also sweeps any per-approval + /// locals a live socket posted but hasn't individually withdrawn, so the lock screen ends clean. + func withdrawApprovalAttention() { + let center = UNUserNotificationCenter.current() + center.removeDeliveredNotifications(withIdentifiers: [Self.approvalTickleIdentifier]) + center.removePendingNotificationRequests(withIdentifiers: [Self.approvalTickleIdentifier]) + center.getDeliveredNotifications { delivered in + let stale = delivered.map(\.request.identifier).filter { $0.hasPrefix("approval-") } + guard !stale.isEmpty else { return } + center.removeDeliveredNotifications(withIdentifiers: stale) + } + } + /// Keep the app-icon badge equal to the NEEDS YOU count (UX_IOS §8). func updateBadge(_ count: Int) { UNUserNotificationCenter.current().setBadgeCount(count)