How to make count-down within watch complication?

851 views Asked by At

I'm working on a complication that should provide a count-down in minutes? Say user specified it to be 25 mins, so the complication should update the count every minute until it hits 0.

From what I researched, complication should be updated using scheduleBackgroundRefresh API call. However, looks like apple doesn't guarantee the precise time of when watchOS will wake up the app. Also, scheduling a refresh every minute seems a wrong way to go about it.

I also thought of supplying all the values within getTimelineEntries inside my implementation of CLKComplicationDataSource. However, that also didn't work well.

Is there a proper and reliable way to make that kind of stop-watch-like complication?

1

There are 1 answers

0
ymotov On BEST ANSWER

Got it working using CLKRelativeDateTextProvider. From apple docs:

You use a relative date text provider to implement timers or other relative time values in an efficient way. Instead of using multiple timeline entries to replicate a countdown timer, create a single timeline entry with a relative date text provider.