'Limit amount of widgets that can be added to iOS app by user

I have app that lets users to add widgets, my widgets are configurable (they can present different content), I want to limit amount of widget instances that can be added by user on single device

is there any way for it as I didn't find anything related to that in Apple documentation about widgets and widgetConfiguration?

possible solution: Store some variable with amount of already added widgets in UserDefaults. It won't prevent from adding new widgets but will help to show some information about limitations for user.

enter image description here



Solution 1:[1]

This is impossible. You don’t know when widgets are created or removed; you only know when their timelines are reloaded. If you use ConfigurationIntents, you’ll see that they have unique IDs, which may seem promising; but I can tell you from my own testing, if multiple widgets use identical configurations then you’ll only see the one configuration. So AFAIK, there is absolutely no way to know how many widgets are active at any given time.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adam