目前,我的代码不起作用。我仍然需要手动刷新它。我希望并发症每 12 小时自动更新一次。
func getTimelineStartDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
let date = Calendar.current.startOfDay(for: Date())
print("timeline start date :\(date)")
handler(date)
}
func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
var date = Calendar.current.startOfDay(for: Date())
date = Calendar.current.date(byAdding: .day, value: 2, to: date)!
print("timeline end date:\(date)")
handler(date)
}
func getNextRequestedUpdateDate(handler: @escaping (Date?) -> Void){
handler(Date(timeIntervalSinceNow: 60*60*12))
}