Hi, the live activity function should look something like:
func startLiveActivity() {
let attributes = TimerAttributes(/*…*/)
let contentState = TimerAttributes.ContentState(/*…*/)
Task { @MainActor in
do {
let activity = try Activity<TimerAttributes>.request(
attributes: attributes,
content: ActivityContent(state: contentState, staleDate: staleDate),
pushType: nil
)
self.activity = activity
} catch {
print("Failed to start Live Activity: \(error)")
}
}
}
My TimerAttributes - this is your attributes for Live Activity, defined as:
struct TimerAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
/* content state variables */
}
/* other variables here */
}
so when ever you call your start, you have to call your Live Activity start function. I place it in a Live Activity Manager.