Contents

request(attributes:contentState:pushType:)

Requests and starts a Live Activity.

Declaration

static func request(attributes: Attributes, contentState: Activity<Attributes>.ContentState, pushType: PushType? = nil) throws -> Activity<Attributes>

Parameters

  • attributes:

    A set of attributes that describe the Live Activity and its static content.

  • contentState:

    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 nil to 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.

Return Value

The object that represents the started Live Activity.

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.

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.

See Also

Deprecated