I wanted to show count down timer in live activity. Since we can't use Timer in extensions, I used Text.init(timerInterval:pauseTime:countsDown:showsHours:)
to show timer. But I need to show different text when the timer ends. How to achieve this behaviour?
How to show count down timer in live activity?
Yes this is correct for timers.
To update the state when countdown reaches 0 here are some options:
-
Use a background task to end the live activity. You can set the “final state” here and choose the dismissal policy
-
set the
staleDate
and check in your view if data is stale -
use push notifications
I tried to observe the Stale state , but for stale state,I got call back only when I opened the app by tapping live activity. Otherwise the stale state change is not observed by activityStateUpdates
even after the stale date
Did you found some workaround for this or not ?? @Praveenraj4256
set the staleDate and check in your view if data is stale
It's not documented anywhere, but staleDate
has a minimum of 2 minutes from the activities start. So if you set a date any time before that, it won't fire for at least 120 seconds.