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.

Solved 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.

5 Replies

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?