How to create widgets with new app intents?

Generated on 8/4/2024

1 search

To create widgets with new app intents, you can follow these steps:

  1. Define the Configuration Intent: This is an intent that conforms to WidgetConfigurationIntent. It needs to have a title and parameters that allow for customization. For example, if you want your widget to be configurable with a specific entity like a trail, you can add a parameter for it.

  2. Set Up the Widget: Use the configuration intent in your widget's body. This involves setting the configuration intent type for the widget and ensuring that the parameters are correctly defined and optional if necessary.

  3. Interactive Widgets: With the new capabilities, you can create widgets with multiple interactive areas that perform actions and update state directly within the widget. This includes using buttons and toggles to perform actions without leaving the widget.

  4. Relevant Contexts: Specify relevant contexts such as time of day, location, or routine to ensure that your widget appears in the smart stack at the most useful times.

For more detailed guidance, you can refer to the session Bring your app’s core features to users with App Intents (17:02).

Additionally, the session What’s new in watchOS 11 (05:01) discusses how to bring interactive widgets to watchOS using the same APIs as on iOS and macOS, which might be useful if you're targeting multiple platforms.