Skip to content

Add scheduleEnd to dismiss a Live Activity at a future date#180

Open
jenow wants to merge 2 commits into
istornz:mainfrom
jenow:feat/schedule-end
Open

Add scheduleEnd to dismiss a Live Activity at a future date#180
jenow wants to merge 2 commits into
istornz:mainfrom
jenow:feat/schedule-end

Conversation

@jenow

@jenow jenow commented Jun 29, 2026

Copy link
Copy Markdown

Right now endActivity is the only way to stop an activity, and it dismisses it
immediately. I ran into a case where I wanted to end one but have the system keep
it on the lock screen until a set time and then drop it on its own, even if the
app gets killed in the meantime and no push ever shows up.

ActivityKit already handles this with end(dismissalPolicy: .after(date)), it
just wasn't exposed anywhere, so this wires it up as scheduleEnd:

await liveActivities.scheduleEnd(activityId, at: endDate);

A couple of things about how .after actually behaves that tripped me up:

  • the activity leaves the Dynamic Island right away
  • you can't update it after that, but a Text(.timer) keeps counting down on the
    lock screen card by itself
  • iOS won't keep it around more than 4 hours past the end call

One thing I had to work around: once you schedule the end, the activity is gone
from Activity.activities, so a plain endActivity can't find it to clear it
early. I keep a reference to the ended activity so endActivity can still kill
the card immediately if you need it gone before the timer's up (cancelled
countdown, etc.).

iOS 16.1+. Also added a scheduleEnd stub to the test mock so the platform
interface test still compiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant