Launch Activity Logic
Nucleic-Session: EBB24271-3AB2-4CBD-A47A-59FC73500371 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -195,6 +195,12 @@ final class LiveActivityManager {
|
|||||||
/// bridge setup; the guards keep a single observer each.
|
/// bridge setup; the guards keep a single observer each.
|
||||||
func beginPushToStartObservation() {
|
func beginPushToStartObservation() {
|
||||||
guard ActivityAuthorizationInfo().areActivitiesEnabled else { return }
|
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 {
|
if pushToStartObservation == nil {
|
||||||
pushToStartObservation = Task { [weak self] in
|
pushToStartObservation = Task { [weak self] in
|
||||||
for await data in Activity<NucleicSessionAttributes>.pushToStartTokenUpdates {
|
for await data in Activity<NucleicSessionAttributes>.pushToStartTokenUpdates {
|
||||||
|
|||||||
Reference in New Issue
Block a user