Contents

AppIntentConfiguration

An object describing the content of a widget that uses a custom intent to provide user-configurable options.

Declaration

@MainActor @preconcurrency struct AppIntentConfiguration<Intent, Content> where Intent : WidgetConfigurationIntent, Content : View

Mentioned in

Overview

The following example shows the configuration for a game widget that displays details about a chosen character.

struct CharacterDetailWidget: Widget {
    var body: some WidgetConfiguration {
        AppIntentConfiguration(
            kind: "com.mygame.character-detail",
            intent: SelectCharacterIntent.self,
            provider: CharacterDetailProvider(),
        ) { entry in
            CharacterDetailView(entry: entry)
        }
        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}

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

The intent is a custom App Intent containing user-editable parameters.

The timeline provider is an object that determines the timeline for refreshing your widget. Providing future dates for updating your widget allows the system to optimize the refresh process.

The content closure contains the SwiftUI views that WidgetKit needs to render the widget. When WidgetKit invokes the content closure, it passes a timeline entry created by the widget provider’s snapshot(for:in:) or timeline(for:in:) method.

Modifiers let you specify the families your widget supports, and the details shown when users add or edit their widgets.

Topics

Creating a widget configuration

Setting the display name

Setting the description

Setting the supported families

Handling background network requests

See Also

Configurable widgets