How to clear installed widgets on iOS app

Viewed 233

In last version of iOS app we have implemented widget feature, but in the coming release we have decided to remove the widget extension.

If the user has already added widget to his Home Screen and when ever user updates his/her application with latest code that does not contain widget extension, still user is able to view blank widget.

Is there any way to clear/remove widgets programatically from main app.

1 Answers

If you set the supportedFamilies modifier on the WidgetConfiguration to [] then the widget no longer shows in the widget gallery. That might be an option.

public var body: some WidgetConfiguration {
    StaticConfiguration(
      kind: kind,
      provider: Provider()
    ) { entry in
      widget_mainEntryView(entry: entry)
    }
    .configurationDisplayName("Foo")
    .description("Foo")
    .supportedFamilies([])
  }
Related