import AppIntents import ActivityKit /// Ends a running task Live Activity directly from its Lock Screen / Dynamic /// Island card — no need to open the app. Runs in the widget extension /// process (that's how LiveActivityIntent works), so it talks to ActivityKit /// directly rather than going through LiveActivityManager (app target only). @available(iOS 17.0, *) struct StopCountdownIntent: LiveActivityIntent { static var title: LocalizedStringResource = "Stop Countdown" static var description = IntentDescription("Ends this task's live countdown.") @Parameter(title: "Task ID") var taskID: String init() {} init(taskID: String) { self.taskID = taskID } func perform() async throws -> some IntentResult { for activity in Activity.activities where activity.attributes.taskID == taskID { await activity.end(nil, dismissalPolicy: .immediate) } return .result() } }