SwiftUI Widgets with Siri Intent for dynamic list of options

1.1k views Asked by At

With iOS 14 and the new widgets you can either have a StaticConfiguration or an IntentConfiguration where you define a custom intent. I have created a simple Intent in the intent configuration file called "MySimpleIntent". Code is generated by Xcode.

I went on and created an Intent Extension in order to provide a dynamic list of options (when editing the widget). Usually the list is always the same with all widgets, however I specifically need to filter the list of results based on the widget family.

Do you know how I can retrieve the widget family from an Intent / Intent Configuration? I get can all current widgets using the WidgetCenter.shared.getConfigurations, however I can't properly filter them by intent identifier.

Any help is appreciated!

1

There are 1 answers

1
Ludyem On

I haven't tested it, but on top of my head I guess you can just create a different Intent for the list that you need filtered and add another func getTimeline using that IntentConfiguration on the same widget