Use sendLiveActivityNotification to manage the lifecycle of an existing Live Activity. The contentState must conform to Encodable and Sendable and match the activity's configuration.
To Update: Set the event to .update.
To End: Set the event to .end. You can optionally provide a dismissalDate to alter default behavior.
// Update
try await client.sendLiveActivityNotification(
.init(
expiration: .immediately,
priority: .immediately,
appID: "com.app.bundle",
contentState: ContentState,
event: .update,
timestamp: Int(Date().timeIntervalSince1970)
),
deviceToken: activityPushToken
)
// End
try await client.sendLiveActivityNotification(
.init(
expiration: .immediately,
priority: .immediately,
appID: "com.app.bundle",
contentState: ContentState,
event: .end,
timestamp: Int(Date().timeIntervalSince1970),
dismissalDate: .immediately // Optional to alter default behaviour
),
deviceToken: activityPushToken
)