I want to query steps from HealthKit every 15mins to update my Complication via WidgetKit.
In the Timeline Provider getTimeline() I execute the query, create one timeline entry with the steps and set timeline refresh policy to .after(now + 15min).
Currently I am stuck because the refresh is never triggered. The steps are queried and shown after initially setting the complication on the Watchface but never refresh.
`
func getTimeline(in context: Context, completion: @escaping (Timeline<HealthKitWidgetEntry>) -> Void) {
let currentDate = Date()
let refreshMinuteGranuity = 15
let refreshDate = Calendar.current.date(
byAdding: .minute,
value: refreshMinuteGranuity,
to: currentDate
)!
healthData.getTodaysSteps { steps in
let entry = HealthKitWidgetEntry(
date: currentDate, steps: steps
)
let timeline = Timeline(
entries: [entry], policy: .after(refreshDate)
)
print("Next refresh: \(refreshDate)")
completion(timeline)
}
}
`
Any input on how to solve this?