diff --git a/NucleicRemote/NucleicRemote/Models/RemoteStore.swift b/NucleicRemote/NucleicRemote/Models/RemoteStore.swift index aa0093b..50f56b4 100644 --- a/NucleicRemote/NucleicRemote/Models/RemoteStore.swift +++ b/NucleicRemote/NucleicRemote/Models/RemoteStore.swift @@ -1251,6 +1251,21 @@ final class RemoteStore: ObservableObject { } } + /// Send the current push-to-start token to every live, capable host that hasn't got it yet — the + /// mirror of `syncLiveActivityRegistration` for the device-scoped token that lets a host create + /// the glance over APNs when work starts before the app is opened (iOS 17.2+). + private func syncPushToStartRegistration() { + guard let token = pushToStartToken else { return } + // A host that dropped should re-register when it returns. + pushToStartSentTo = pushToStartSentTo.filter { connections[$0]?.connectivity.isLive == true } + for (id, conn) in connections { + guard conn.connectivity.isLive, conn.capabilities.canPushLiveActivity, + !pushToStartSentTo.contains(id) else { continue } + conn.send(.registerPushToStartToken(token)) + pushToStartSentTo.insert(id) + } + } + // MARK: - Demo simulator (offline, interactive) // // In demo mode there's no host, so writes can't go over the wire. Instead they mutate the