Timeline
An object that specifies a date for WidgetKit to update a widget’s view.
Declaration
struct Timeline<EntryType> where EntryType : TimelineEntryMentioned in
Overview
To tell WidgetKit when to update a widget’s view, TimelineProvider generates a timeline. The timeline contains an array of timeline entry objects and a refresh policy.
To create timeline entries, declare a custom type that conforms to TimelineEntry. Each entry specifies the date you would like WidgetKit to update the widget’s view, and any additional information that your widget needs to render the view. Timeline entries may also include information about their relevance compared to other entries in timelines for the same widget kind. WidgetKit uses this relevance information when considering whether a widget should be promoted in a stack. For more about supplying relevance information, see TimelineEntryRelevance.
The timeline’s refresh policy specifies the earliest date for WidgetKit to request a new timeline from the provider. The default refresh policy, atEnd, tells WidgetKit to request a new timeline after the last date in the array of timeline entries you provide. However, you can use after(_:) to indicate a different date either earlier or later than the default date. Specify an earlier date if you know there’s a point in time before the end of your timeline entries that may alter the timeline. Conversely, specify a later date if you know that after the last date, your timeline won’t change for some period of time. Alternatively, use never to tell WidgetKit not to request a new timeline at all. In that case, your app uses WidgetCenter to prompt WidgetKit to request a new timeline.
For more information about generating timelines, see TimelineProvider.