0
votes

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?

1

1 Answers

0
votes

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")