Contents

request(attributes:content:pushType:)

Requests and starts a standard Live Activity.

Declaration

static func request(attributes: Attributes, content: ActivityContent<Activity<Attributes>.ContentState>, pushType: PushType? = nil) 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 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.

Mentioned in

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 Live Activity that started continues until the app, a push notification, or a person ends it, or until it exceeds the maximum duration for Live Activities.

Using this function is the same as passing ActivityStyle.standard to request(attributes:content:pushType:style:). To request a Live Activity that displays the expanded presentation in the Dynamic Island while the app is visible and ends automatically when a person performs other actions, use request(attributes:content:pushType:style:) and pass ActivityStyle.transient to its style parameter.

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

Starting a Live Activity