How do configurable widgets, interactive buttons and Control Center controls work with App Intents?

19.4.2 · L5 · Interview

Predict first

Which fits a “mark as done” control that must work from the Home Screen without opening the app?

// A: a Button(intent:) in the widget, running an App Intent that updates shared state and reloads the timeline
// B: a UITextField in the widget
// C: a timer in the widget view that polls the server
  • A
  • B
  • C

Mental model. An interactive widget button is a light switch on the billboard wired to a small electrician (the intent). Pressing it sends the electrician to do one job at once, with no need to open the house (the app), and then the billboard redraws to show the new state.

Since iOS 17 widgets can do more than display. Configurable widgets use an AppIntentConfiguration: the widget declares an WidgetConfigurationIntent (an App Intent with @Parameters such as a chosen list, a city or a colour), the user edits the widget (long-press, Edit Widget) and the system persists the answers, passing the intent to your AppIntentTimelineProvider in timeline(for:in:). Parameters can have dynamic options (EntityQuery providing the available lists or accounts) and defaults, and you can declare relevance so the Smart Stack surfaces the widget at the right time. Interactive widgets embed Button(intent:) and Toggle(isOn:intent:) in the SwiftUI view: tapping runs the intent’s perform() without launching the app, in the widget extension’s process (or in the app’s process if the intent is declared to run there, by being a member of the app target or by its openAppWhenRun), then the system reloads the timeline so the view reflects the change. These are the only interactive elements: no text fields, scrolling or arbitrary gestures. The intent’s perform() must be quick and robust (it runs under the extension limits), should update shared state (the app group database) and may call WidgetCenter reload; it returns a result and can fail with an error. The same intents appear in Shortcuts and Siri, so write them once as the single entry point for “do this action”, with parameter types, titles and dialog.

Control Center and Lock Screen controls (iOS 18, ControlWidget) are small, glanceable buttons and toggles you add as a widget extension: a ControlWidgetButton runs an intent, a ControlWidgetToggle shows and flips a boolean state, both with a label and symbol, and a ControlValueProvider supplies current state (asynchronously, with a placeholder); they can open an app via an OpenIntent and be configured with an intent. Design rules for all of these: keep an intent’s work tiny and idempotent; return fresh state fast so the UI is right after the reload; share a model layer with the app so the widget, the app and Shortcuts agree; handle the case where the intent runs while the app is not running (no singletons, no UI); respect authentication (an intent that changes secure state can require device unlock through authenticationPolicy); and give intents good titles and parameter summaries since they surface in the Shortcuts app, Spotlight and Siri. Test the intent code as plain Swift (you can call perform() directly, and it is just an async throws function with parameters set), then test the widget on a device including the timeline reload after the action. Live Activities are the third family on this surface, covered in the system frameworks topic, with buttons that run intents in the same way.

Widgets support buttons and toggles tied to App Intents; text fields and timers are not available.

Common traps

  • Putting heavy or long-running work in a widget intent’s perform(). It runs under extension limits; keep it tiny or hand off to the app.
  • Writing the widget’s state somewhere the timeline cannot read. Update the shared container so the reloaded timeline shows the change.

They might follow up with

  • Does tapping a widget button launch the app? No: it runs the intent in the background and reloads the timeline.
  • Which elements can be interactive in a widget? Buttons and toggles bound to App Intents only.

Related questions

  • 19.4.1 How does a WidgetKit widget work: providers, timeline entries, reload policies, families and the refresh…
  • 19.5.1 What are App Intents, App Entities and App Shortcuts, how do they replace SiriKit and Intents extensions, and…
  • 19.1.2 How do app groups, shared containers and keychain access groups let an app and its extensions share data, and…

← How does a WidgetKit widget work: providers, timeline entries, reload…