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:38 -07:00
co-authored by Nucleic
parent 393b2f29f4
commit a5ba88bee2
@@ -195,6 +195,12 @@ final class LiveActivityManager {
/// bridge setup; the guards keep a single observer each.
func beginPushToStartObservation() {
guard ActivityAuthorizationInfo().areActivitiesEnabled else { return }
// Grab an activity that already exists when we start observing — e.g. one a Mac push-started
// while the app was closed, which won't re-emit through `activityUpdates` for a late observer.
// This is what lets a background "adopt" wake harvest and forward its update token.
if activity == nil, let existing = Activity<NucleicSessionAttributes>.activities.first {
adopt(existing)
}
if pushToStartObservation == nil {
pushToStartObservation = Task { [weak self] in
for await data in Activity<NucleicSessionAttributes>.pushToStartTokenUpdates {