Dynamically control iOS widget visibility based on app login status

Hi everyone,

I’m developing an iOS app and would like to know if it’s possible to dynamically show or hide a widget in the iOS Widget Gallery based on the user’s login status in the app.

For example:

  1. When a user logs in to the app, the widget should appear in the Widget Gallery.
  2. When the user logs out, the widget should be hidden or removed from the Widget Gallery.

Is this behavior supported by iOS? Can an app dynamically control the visibility or availability of its widget in the Widget Gallery based on the user’s authentication status?

If this is not directly supported, is there an alternative or recommended approach using WidgetKit?

Since my app has multiple widgets, some of them specifically require users to log in before they can be used. That’s why I wanted to implement this kind of behavior.

Any guidance or suggestions would be appreciated.

Thank you!