request(attributes:content:pushType:style:alertConfiguration:start:)
Requests and schedules a Live Activity for a specific date.
Declaration
static func request(attributes: Attributes, content: ActivityContent<Activity<Attributes>.ContentState>, pushType: PushType? = nil, style: ActivityStyle, alertConfiguration: AlertConfiguration, start: Date) throws -> Activity<Attributes>Parameters
- attributes:
A set of attributes that describe the Live Activity and its static content.
- content:
A structure that describes the dynamic content of the Live Activity that changes over time.
- pushType:
A value that indicates whether the Live Activity receives updates to its dynamic content with ActivityKit push notifications. Pass
nilto start a Live Activity that only receives updates from the app with the Update(_:) function. To start a Live Activity that receives updates to its dynamic content with ActivityKit push notifications in addition to the Update(_:) function, pass Token to this parameter. - style:
A flag that indicates whether the Live Activity uses standard or transient behavior. For most apps, passing Standard is the best choice. It starts a standard Live Activity that continues until the app, a push notification, or a person ends it, or until it exceeds the maximum duration for Live Activities. By passing Transient, you start a Live Activity that appears in the extended presentation in the Dynamic Island but ends automatically when a person automatically locks the device, collapses the extended presentation, leaves the app, or performs other tasks outside the Dynamic Island.
- alertConfiguration:
The alert configuration you use to configure how the system notifies a person about the updated content of the Live Activity.
- start:
The date to schedule the start of your Live Activity; for example, for an upcoming sports game. You must provide an
alertConfigurationto let people know that your app started a Live Activity. The Activitystate for a scheduled but not yet started Live Activity is Pending.
Return Value
The object that represents the Live Activity you started.
Discussion
Use this function to request and start a Live Activity from your app while it’s in the foreground. Note that you can’t do this while your app is in the background, unless you adopt App Intents and start the Live Activity using a LiveActivityIntent.
The system starts the Live Activity at the specified date, even if the app is in the background. Note that you must provide an AlertConfiguration. This makes sure that the system notifies people when your app starts the Live Activity.
If your Live Activity displays image assets, the system requires them to use a resolution that’s smaller or equal to the size of the Live Activity presentation for a device. If you use an image asset that’s larger than the size of the Live Activity presentation, the system may fail to start the Live Activity. For information about the sizes of Live Activity presentations, see Human Interface Guidelines > Live Activities.
For additional information on starting a Live Activity, see Displaying live data with Live Activities.