I have a live activity that has a countdown timer. The timer can be minutes long. If my app is suspended the countdown timer reaches zero and then starts to count up. I have set the stale date of the ActivityContent to be the same date as the countdown timer. I have code in the widget that displays if the state is stale. This code is updated about 1:45 after the stale date has occurred.
How can I make sure the UI updates right when the stale date occurs when the app is suspended?
@available(iOS 16.2, *)
struct IsStaleWidget: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: MyActivityAttributes.self) { context in
Text("\(context.isStale ? "Is" : "Not") stale")
} dynamicIsland: { context in
DynamicIsland {
DynamicIslandExpandedRegion(.center) {
Text("\(context.isStale ? "Is" : "Not") stale")
}
} compactLeading: {
Text("\(context.isStale ? "Is" : "Not")")
} compactTrailing: {
Text("Stale")
} minimal: {
Text("\(context.isStale ? "S" : "!S")")
}
}
}
}