Widget getSnapshot method won't call for second time

Hi,

We have shipping status widget where user can track package once he logged in the app, the problem now is for the first time it calls getSnapshot method show correct information BUT suppose if user logged out in main app and try to add widget during that time getSnapshot won't get called instead it shows previous cached data, any idea how to make getSnapshot called always when user in gallery?
There is no guarantee that getSnapshot will be called each time the galley is opened, the OS might cache previous results as you've seen.

In the case the user has never logged in to the app and adds the widget, so their is no previous cached data in your getSnapshot call you could check the auth status of your app and if the user is logged out:
  1. Show a "Logged out" UI in the widget

  2. Show some canned data to fill out your widget with example data (to make it look good in the gallery).

Then once the user logs in via the app you can get the widget to refresh its UI by calling: https://developer.apple.com/documentation/widgetkit/widgetcenter/reloadalltimelines()

For the other case where you don't want cached data in the gallery once the user logs out, you could try calling reloadAllTimelines() when the user logs out in the app and see if that causes the snapshot to be updated.

Thanks for the reply, i have implemented such reloading(reloadalltimelines()) logic on main app when user login or logout but that's not triggering timeline methods getSnapshot again when user open the gallery second time it's still caching data it seems also what i observed even if you call reloadalltimelines() frequently then timeline provider methods won't get called immediately instead it will call after few mins
Widget getSnapshot method won't call for second time
 
 
Q