0

https://developer.apple.com/documentation/widgetkit/widgetinfo/kind

Do we have to use a reverse dns notation for our widget name eg “com.server.app.widget.highscore”?

Should the name be globally unique? Or only unique within the app? Or only unique within the app widget extension?

pawello2222
  • 46,897
  • 22
  • 145
  • 209
HixField
  • 3,538
  • 1
  • 28
  • 54

1 Answers1

0

From the documentation:

/// Every widget has a unique `kind`, a string that you choose. You use this
/// string to identify your widget when reloading its timeline with
/// <doc:WidgetCenter>.

The kind should be unique for your app.

It's used for example to refresh only a group of widgets of the same kind:

WidgetCenter.shared.reloadTimelines(ofKind: "<widget_kind>")

Every widget that comes from your app should have a different kind, otherwise if you call .reloadTimelines(ofKind:) you will refresh multiple widgets.

However, in the documentation, Apple seems to favour the reverse domain name notation - I suggest you can follow the same pattern.

Here are some examples from the documentation:

///     struct CharacterDetailWidget: Widget {
///         var body: some WidgetConfiguration {
///             StaticConfiguration(
///                 kind: "com.mygame.character-detail",
///                 provider: CharacterDetailProvider()) { entry in
///                 CharacterDetailView(entry: entry)
///             }
///             .configurationDisplayName("Character Details")
///             .description("Displays a character's health and other details")
///             .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
///         }
///     }
///
/// WidgetCenter.shared.reloadTimelines(ofKind: "com.mygame.gamestatus")
pawello2222
  • 46,897
  • 22
  • 145
  • 209
  • Yes indeed Apple favors reverse domain notation. But its all a bit vague – HixField Mar 06 '21 at 11:12
  • Actually I experienced some strange behaviour in my app between DEV and PROD builds with different bundleIds that leads me to think its probably safer to go for globally unique names using reverse dns... strange was widgets could not be installed for a DEV build while PROD build was already installed even when they have different bundleid... – HixField Mar 06 '21 at 11:50