In this link (Apple Developer Document) use this to update a widget:
This is my Code right now:
What am I doing wrong?
Can someone please help me to integrate a refresh policy?
Code Block // Request a timeline refresh after 2.5 hours. let date = Calendar.current.date(byAdding: .minute, value: 150, to: Date()) let timeline = Timeline(entries: entries, policy: .after(date)) completion(timeline)
This is my Code right now:
Code Block struct Provider: IntentTimelineProvider { let networkManager = NetworkManager() func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date(), configuration: ConfigurationIntent(), clubnamehome: networkManager.clubNameHome) } func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) { let entry = SimpleEntry(date: Date(), configuration: configuration, clubnamehome: networkManager.clubNameHome) completion(entry) } func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. let currentDate = Date() for hourOffset in 0 ..< 5 { let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! let entry = SimpleEntry(date: entryDate, configuration: configuration, clubnamehome: networkManager.clubNameHome) entries.append(entry) } //wie oft geupdatet werden soll let date = Calendar.current.date(byAdding: .minute, value: 15, to: Date()) let timeline = Timeline(entries: entries, policy: .after(date!)) completion(timeline) } }
What am I doing wrong?
Can someone please help me to integrate a refresh policy?