Teach me about interactive widgets

Asked on 2024-08-10

1 search

Interactive widgets are a feature that allows users to perform actions directly from a widget without needing to open the app. This functionality is available across iOS, macOS, and watchOS. In watchOS 11, interactive widgets have been introduced, enabling users to perform quick actions, such as locking or unlocking a door, directly from the widget interface. This is achieved by using buttons and toggles within the widget, which are implemented using SwiftUI and App Intents.

To create an interactive widget, you would typically define a SwiftUI button within the widget view and implement the perform method in your widget's intent to specify the action. For example, tapping a button could trigger an action like locking a door. The interactive widgets support multiple interactions, although the practicality of this depends on the widget's shape and size.

For more detailed guidance on implementing interactive widgets, you can refer to the session What’s new in watchOS 11 (05:57) which covers the introduction of interactive widgets in watchOS 11.

Teach me about interactive widgets | Ask WWDC