I currently have an iPhone application that renders a list view full of timers. The user is able to swipe on any row and "track" that timer. Tracking it initiates a live activity containing details for the timer to display. This all works great.
NOW, I want to update my list view so that for any timer that is presently being tracked via a live activity, the swipeAction's label should change to "untrack" AND I want to render a little pin icon in the corner of the row to indicate that the timer for that row is pinned.
How do I do this? Once I spawn the live activity, my application does not keep a reference of which are running for purposes of updating the list view. This seems pointless, since anything I remember would be in-memory and likely to be evicted after the user quits the app anyway.
How do I integrate knowledge of "which active live activities are running for my app" into the list view so that the user can clear live activities from within the application?
You can get a list of all the live activities that your app is currently displaying with the
activities static property of the
Activity type in ActivityKit. From there, you can compare its
id property to that of the model backing each row of your list to determine whether an activity is currently displaying for a particular row or not and make decisions based on that