I'm trying to build a live activity with the new iOS 17.0 interactivity, and I want a button on the live activity to update the live activity when clicked (e.g. start a timer).
This works fine with a widget, but with live activities it doesn't seem like the activity view gets refreshed instantly.
As a workaround, I tried putting the activity.update
code in the button's intent's perform
method. This doesn't seem to work as the intent gets executed from the widget extension, which seems to always have an empty activities
(link) array.
Question: Is activity.update
only meant to be called from the app (either foregrounded or in a background task), or should it also be possible to be called in the WidgetExtension itself?
Ideally I'd be able to avoid using push notifications, which seems overkill for e.g. just at timer.
Related thread: Changing the live activity without push notification
Aha, so the issue was that I did not include the intent in the application bundle. Once I did that, the app now performs the update in the application (as opposed to the widget extension).
Perhaps this could be clarified in this bit of documentation: https://developer.apple.com/documentation/widgetkit/adding-interactivity-to-widgets-and-live-activities#Implement-the-perform-function