I'm building out a live activity that has a button which is meant to update the content state of the Live Activity. It calls a LiveActivityIntent that runs in the app process.
The push server starts my live activity and the buttons work just fine. I pass the push token back to the server for further updates and when the next update is pushed by the server the buttons no longer work. With the debugger I'm able to verify the app intent code runs and passes the updated state to the activity. However the activity never updates or re-renders. There are no logs in Xcode or Console.app that indicates what the issue could be or that the update is ignored.
I have also tried adding the frequent updates key to my plist with no change.
I'm updating the live activity in the LiveActivityIntent like this:
public func perform() async throws -> some IntentResult {
let activities = Activity<WidgetExtensionAttributes>.activities
for activity in activities {
let currentState = activity.content.state
let currentIndex = currentState.pageIndex ?? 0
let maxIndex = max(0, currentState.items.count - 1)
let newIndex: Int
if forward {
newIndex = min(currentIndex + 1, maxIndex)
} else {
newIndex = max(currentIndex - 1, 0)
}
var newState = currentState
newState.pageIndex = newIndex
await activity.update(
ActivityContent(
state: newState,
staleDate: nil
),
alertConfiguration: nil,
timestamp: Date()
)
}
return .result()
}
To sum up:
Push to start -> tap button on activity -> All good!
Push to start -> push update -> tap button -> No good...