0

I have a simple widget that needs to be updated daily, however many of the users have complained that their widget doesn't update daily.

What am doing wrong here?

func getTimeline(in context: Context, completion: @escaping (Timeline<TodayInfoEntry>) -> Void) {
 
let now = Date() + 2 
widgtBrain.date = now
 
let nextUpdateDate = Calendar.autoupdatingCurrent.date(byAdding: .day, value: 1, to: Calendar.autoupdatingCurrent.startOfDay(for: now))!
 
  let todayInfo = widgtBrain.widgetInfoDicGenerator(forActualWidget: true, forPlaceholder: false, forSnapshot: false)
   
  let entry = TodayInfoEntry(
    date: now,
    info: todayInfo
  )
   
  let timeline = Timeline(
    entries:[entry],
    policy: .after(nextUpdateDate)
  )
   
  completion(timeline)
}

the widgetBrain generates a dictionary with new data based on the given date "now"

jps
  • 20,041
  • 15
  • 75
  • 79
Mona
  • 5,939
  • 3
  • 28
  • 33
  • There's not enough information in your question but his might help you: [Setting the TimelineProvider refresh interval for Widget](https://stackoverflow.com/a/64014799/8697793) – pawello2222 Dec 22 '20 at 10:45
  • @pawello2222 thank you for your response. I was also thinking the same thing. atEnd is probably more reliable than .after. Thanks – Mona Dec 23 '20 at 04:07

0 Answers0