Post

Replies

Boosts

Views

Activity

Reply to Widgets not displaying data when running on iOS 18
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") }
Sep ’24