How can I end all Live Activities?

361 Views Asked by At

An app can have many Live Activities simultaneously; I am trying to kill them all by doing the following.

for activity in Activity<MyAttributes>.activities {
  Task {
    await activity.end(nil, dismissalPolicy: .immediate)
  }
}

But this doesn't affect the activities that continue being displayed.

1

There are 1 best solutions below

0
fruitcoder On

Can you try two things:

  1. Add an @MainActor in your async context (I don't know if you're working in a main actor isolated view model)
  2. Add a final value for your MyAttributes instead of nil