Launch Activity Logic

Nucleic-Session: EBB24271-3AB2-4CBD-A47A-59FC73500371
Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
2026-07-06 14:04:53 -07:00
co-authored by Nucleic
parent a5ba88bee2
commit aa159817f2
@@ -46,15 +46,28 @@ final class PushAppDelegate: NSObject, UIApplicationDelegate {
// Best-effort: no token → the phone still works on LAN, just no remote wake. // Best-effort: no token → the phone still works on LAN, just no remote wake.
} }
/// Silent pushes. The relay sends a content-free `clear` (content-available) to recall the /// Silent pushes (content-available). Two kinds route here:
/// "waiting for your approval" tickle once the approval is resolved on another device — we /// - `clear`: recall the "waiting for your approval" tickle once the approval is resolved on
/// wake in the background just long enough to withdraw the stale notification. Other silent /// another device — wake briefly to withdraw the stale notification.
/// pushes (e.g. the wake tickle itself, which is an alert) don't route here. /// - `adopt`: a Mac push-started a Live Activity while the app was closed; come online long
/// enough to harvest and register that activity's update token so live updates + a clean end
/// resume without the user opening the app (UX_IOS §5.3). This one holds the completion handler
/// until the token is registered (or the background window closes), so the process isn't
/// suspended mid-connect.
/// Other pushes (e.g. the approval wake tickle, which is an alert) don't route here.
func application( func application(
_ application: UIApplication, _ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any], didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) { ) {
if userInfo["adopt"] != nil {
// The store manages its own background-task assertion for this; report .newData once it
// has brought the connection up and registered the token (or given up).
Task { @MainActor in
RemoteStore.shared.handleLiveActivityAdoptWake { completionHandler(.newData) }
}
return
}
if userInfo["clear"] != nil { if userInfo["clear"] != nil {
// Fire-and-forget on the main actor (NotificationRouter is @MainActor); the removal is a // Fire-and-forget on the main actor (NotificationRouter is @MainActor); the removal is a
// quick UNUserNotificationCenter call, so we can report .noData right away. // quick UNUserNotificationCenter call, so we can report .noData right away.