Hi,
I'm having the following issue:
I'm building an app that has a widget on the lockscreen. The widget displays the elapsed time of a stopwatch. I am reloading the timeline manually each time the app becomes inactive. But it does not reload always. If I swipe to reveal Notifcation Center, although the app becomes inactive, widget will not update.
Although reloadTimeline is called each time, getTimeline(...) function of the TimelineProvider does not get called
I need to put the app in the background first and then it will refresh. Is this a bug in the framework?
Thanks guys in advance for your answers!
Below is the code
NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: nil) { _ in
WidgetCenter.shared.reloadAllTimelines()
}
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
print(#function)
dataFetcher.fetch { bubbleData in
var entries = [Entry]()
let currentClock = TimeInterval(bubbleData.isTimer ? bubbleData.value : -bubbleData.value)
let input = Entry.Input(isRunning: bubbleData.isRunning, startValue: currentClock, isTimer: bubbleData.isTimer)
let entry = Entry(date: Date(), configuration: ConfigurationIntent(), input: input)
entries.append(entry)
let timeline = Timeline(entries: entries, policy: .never)
completion(timeline)
}
}