Live Activity compact timers

The Human Interface Guidelines for Live Activities provide several examples of compact presentations that have a timer counting down formatted like "3min" or "3m", similar to the timers in the Clock app. Such examples can be found in this Stack Overflow question: https://stackoverflow.com/questions/77551496/is-it-possible-to-make-an-only-minutes-1m-countdown-in-a-live-activity

A Timer initialized with init(timerInterval:pauseTime:countsDown:showsHours:) has provided a live countdown timer in widgets and live activities, but the formatting is limited. And since live activities come with limitations that prevent us from using Timers, there's no real way to implement this kind of thing ourselves.

What is Apple's official guidance for implementing this kind of timer for the compact presentation?

Hi @tjhorner ,

I think you're looking for this: https://developer.apple.com/documentation/swiftui/text/init(_:format:)-9d2x4

It's the newly introduced text formatter for dates.

As a heads up, here's a post I answered about what seems to be a bug in this timer-wise though: https://forums.developer.apple.com/forums/thread/756971

If you also run into this, I'd really appreciate it if you also file a feedback report and paste the FB number here.

Live Activity compact timers
 
 
Q