WidgetKit won't request a new timeline at the end

When I run the code snippet below, WidgetKit is supposed to request a new timeline at the end of each minute according to the Apple's documentation.

Code Block
let currentDate = Date()
let futureDate = Calendar.current.date(byAdding: .minute, value: 1, to: currentDate)!
let timeline = Timeline(entries: [
      Entry(date: currentDate, number: Int.random(in: 0...10))], policy: .after(futureDate))
completion(timeline)


But it just works once and nothing happens afterward. I am trying it on iOS 14 Beta 2.

Answered by Documentation Engineer in 619739022
Updating every minute is far too aggressive. Widgets have a limited number of updates and if you were to try to update every minute, you'll quickly run out of updates. While debugging with Xcode these limits are not imposed, but if you're running your app outside of Xcode you'd see the behavior you're describing where your widget would stop updating.

What happens if you update every 15 minutes? If that doesn't work, please file a Feedback Assistant report with the details of what you're doing and the results you see.
Accepted Answer
Updating every minute is far too aggressive. Widgets have a limited number of updates and if you were to try to update every minute, you'll quickly run out of updates. While debugging with Xcode these limits are not imposed, but if you're running your app outside of Xcode you'd see the behavior you're describing where your widget would stop updating.

What happens if you update every 15 minutes? If that doesn't work, please file a Feedback Assistant report with the details of what you're doing and the results you see.
I have a similar problem. Have an app that get's readings in the background from a continuous glucose monitor every 3 minutes. I tried calling WidgetCenter.reloadAllTimelines() when a new reading is received but the widget doesn't update that frequent making it useless fora way to monitor the glucose readings.
If your app is able to run in the background you can trigger the getTimeline by using

Code Block
WidgetCenter.shared.reloadTimelines(ofKind:)

In my app I can trigger the widget every second.


If your app is able to run in the background you can trigger the getTimeline by using 

Code Block
WidgetCenter.shared.reloadTimelines(ofKind:)

In my app I can trigger the widget every second.
How did you do this? @PrinzAkim
pdm: What is the number of allowed updates?
I also would like to know what the minimum duration between refreshes is.

Our app has a widget that shows relevant information about the user’s route to work/home. We ask the user what the depart time will be to home/work every day so we refresh the widget every 5 mins during a window of 30 mins around the depart time.

Is that a use case we shouldn’t support? We see the widget updating correctly after adding but after some time (a day or so) the updating stops and even ‘reloadAllTimelines’ doesn’t cause ‘getTimeline’ to be called anymore
WidgetKit won't request a new timeline at the end
 
 
Q