iOS SwiftUI widget issue, the widget load old/default data when is added to lockscreen / home on a physical device

Viewed 91

forgive me if I say nonsense, I have been fiddling with swift for just over 2 months ...be patient :-)

So, I have a problem with the widget and I don't understand what it depends on, maybe it happened to someone and it could help me.

Everything works perfectly, app and widget update, except one (damned) thing: when I add the widget from the gallery for the first time, it loads me the default data. Let me explain: when selecting from the widget gallery the snapshots are updated correctly; when I select it it flashes on an old view (something I would say imperceptible even if it bothers me personally) and then, no one knows why, it loads the default data when it is added to the home / lockscreen, as if the userdefaults were empty .

On the simulator it loads it well, on my device it doesn't (iPhone 7). I would like to understand, from you who know more than me, how the views are divided at the juncture of the gallery: from what I understand, when I see the preview from the gallery it is the getSnapshot: in that context, I load the data from the Userdefaults store to get an updated preview; the same goes for the placeholder since I don't have to fetch anything and therefore I should have the result immediately (but I didn't really understand where the placeholder would appear .. maybe it's that flash I hate so much?).

in getTimeline I do the same, I load the data from the store and then in the for of the timeline I recall them. has it ever happened to anyone?

I would like to post code but I do not have the possibility for various reasons .. i'm really sorry.

thank you very much to those who will try to help me!

0 Answers
Related