SwiftUI Text(_, style: .timer) bug in Live Activity

1.1k views Asked by At

I added the Text(Date().addingTimeInterval(2400), style: .timer) in my Live Activity, but when its countdown to zero and the notification hasn't been delivered yet it starts to count up.

Is it can be fixed?

I tried to use the normal Timer but in the Live Activity it doesn't work

1

There are 1 answers

1
Heikki Hautala On BEST ANSWER

Use this initializer instead: https://developer.apple.com/documentation/swiftui/text/init(timerinterval:pausetime:countsdown:showshours:)

So in your case:

let range = Date()...Date().addingTimeInterval(2400)

Text(
   timerInterval: range,
   pauseTime: range.lowerBound
)