LiveActivity
interface in Scripting enables your script to present real-time data on the Dynamic Island and Lock Screen, providing quick interactions for you.LiveActivityState
Defines the state of a Live Activity:
active
: The Live Activity is visible and can receive updates.dismissed
: The Live Activity has ended and is no longer visible.ended
: The Live Activity is visible but will no longer update.stale
: The Live Activity's content is outdated and requires an update.LiveActivityDetail
Provides details for each Live Activity instance.
LiveActivityState
.LiveActivityUI
Describes the layout for the Live Activity:
LiveActivityUIBuilder<T>
A function that builds the LiveActivityUI
based on dynamic attributes.
LiveActivityOptions
Options for configuring a Live Activity:
LiveActivityUpdateOptions
and LiveActivityEndOptions
Similar to LiveActivityOptions
, with additional alert configuration for updates and dismissal timing for end options.
Creates a new Live Activity using a UI builder function.
string | undefined
- ID of the Live Activity after start
is executed.boolean
- Indicates whether the Live Activity has started.start(attributes: T, options?: LiveActivityOptions): Promise<boolean>
Starts a Live Activity with the specified attributes and options. Returns true
if successful.
update(attributes: T, options?: LiveActivityUpdateOptions): Promise<boolean>
Updates the Live Activity's dynamic attributes. Alerts the user if specified in options
.
end(attributes: T, options?: LiveActivityEndOptions): Promise<boolean>
Ends an active Live Activity with optional final attributes and end options.
getActivityState(): Promise<LiveActivityState | null>
Retrieves the current state of the Live Activity.
addUpdateListener(listener: (state: LiveActivityState) => void): void
Adds a listener for state changes in the Live Activity.
removeUpdateListener(listener: (state: LiveActivityState) => void): void
Removes the specified update listener.
areActivitiesEnabled()
: Checks if Live Activities can be started.addActivitiesEnabledListener(listener: LiveActivityActivitiesEnabledListener)
: Adds a listener for changes to activities-enabled status.getAllActivities()
: Returns an array of all active Live Activities.getAllActivitiesIds()
: Returns the IDs of all active Live Activities.endAllActivities(options?: LiveActivityEndOptions)
: Ends all active Live Activities.In these examples, the attributes status
, eta
, and icon
are defined consistently and used across start
, update
, and end
to ensure the Live Activity UI displays correctly based on the provided data.