I run the WidgetKit project on iOS 17 in build configuration: release, while debug executable is working, it works fine, I click on the button in the widget everything works, but without it it breaks
Post
Replies
Boosts
Views
Activity
In my app, there's a widget that should change to one color when clicked and then to another color after 10 seconds.
When I click the widget button (linked to the App Intent), the widget should refresh. When I debug, this happens as expected.
However, if I call WidgetCenter.shared.reloadAllTimelines() in the perform() method of AppIntent, the widget timeline doesn't refresh right away. This issue only happens on real devices and isn't always consistent. In the simulator, the widget refreshes as expected.
There is a code:
func getData() async -> [Data] {
do {
let token = try ServiceData.getTokenThrows()
let listData = try await ServiceData.fetchDataNew(token: token) // always return list data
return listData
} catch {
return []
}
}
func entities(for identifiers: [DataModel.ID]) async throws -> [DataModel] {
return await getData().filter {
identifiers.contains($0.id)
}
}
func suggestedEntities() async throws -> [DataModel] {
return await getData()
}
func defaultResult() async -> DataModel? {
return await getData().first
}
}
Sometimes during assembly, when changing user data, the data in WidgetConfiguration Intent @Parameter is not received, although they are in the console, and EntityQuery methods do not throw exceptions. Does anyone have any ideas?