Local Updates to Live Activities ignored after push update

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

Thanks for the post. This is a very interesting question for Live Activity that I would recommend to provide a focused sample project that shows this better than just some code that may not provide the whole picture. The fact that the LiveActivityIntent code runs but the UI doesn't update points to a problem with the activity.update() call itself or how the system is handling it after a push update. Do you get the update token?

When the push server sends an update, it effectively replaces the Live Activity's content. For an Activity object to be valid for an update, it must represent the current state of the Live Activity on the system.

Instead of iterating through all Activity instances, you should pass the Live Activity's ID to your LiveActivityIntent and use that ID to find the specific Activity you want to update.

While you mentioned there were no logs catch low-level system events related to Live Activities and App Intents. I agree with you and should be better log errors and that’s something that will be good to request an enhancement request about the logs!

Looking forward to see your focused sample project.

Albert Pascual
  Worldwide Developer Relations.

Local Updates to Live Activities ignored after push update
 
 
Q