Quick update. In the other apps I’ve written that use exactly the same process to update their widgets, they are updating. They only have a Lock Screen widget and not normal ones. I’m not sure if that difference is enough to cause it not to update at all.
Post
Replies
Boosts
Views
Activity
I use a specific suiteName to send the data through UserDefaults, with my own key.
private func sendWeatherDataToWidget(input: CurrentDataConverted) {
let widgetData: WidgetWeatherData = WidgetWeatherData(theTemp: input.currentTemp,
theMax: input.dailyMaxTemp,
theMin: input.dailyMinTemp,
theTime: input.time,
theTempUnits: input.temperatureUnits,
theLocation: input.location)
let tempData = try! JSONEncoder().encode(widgetData)
UserDefaults(suiteName: "group.com.emkubed.Weewx-Weather")!.set(tempData,forKey: "Weewx-Weather")
WidgetCenter.shared.reloadTimelines(ofKind: "com.emkubed.Weewx-Weather")
logger.debug("Sent data to Widget - hopefully")
}