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:
Show a "Logged out" UI in the widget
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.
Topic:
App & System Services
SubTopic:
General
Tags: