I've implemented 2 different AppIntents, each includes their own AppShortcutsProvider with phrases unique to each AppIntent. Individually, they work great. But, when I try to include both in my app, only the last one defined works.
In my ContentView.onAppear(), I've tried calling:
ShortcutsOne.updateAppShortcutParameters()
ShortcutsTwo.updateAppShortcutParameters()
and only those defined in ShortcutsTwo are recognized by Siri.
I've also tried including ShortcutsTwo's AppShortcut(intent:, phrases) into ShortcutOne's AppShortcutsProvider (since it's static var appShortcuts: is defined as an array, ie, [Shortcuts] - but that doesn't work either.
Overall, I've found the system to be rather temperamental. ie, I have had to power off my iPhone & reboot my Mac to get changes recognized.
Any thoughts on how to get 2 or more AppIntents to work in one app?
I've hacked my way into a solution... turns out that:
- I only need to call .updateAppShortcutParameters() once
- that call to .updateAppShortcutParameters() needs to include an AppShortcut(intent:, phrases:) call for each AppIntent I've written
- the AppShortcutsProvider's appShortcuts:[AppShortcut] array is initialized in a way that I was not expecting... ie, you don't need []s around nor commas between array elements
so, this is what it looks like:
static var appShortcuts: [AppShortcut] {
AppShortcut(intent:IntentOne(), phrases:["phrase 1"] // no commas!
AppShortcut(intent:IntentTwo(), phrases:["phrase 2"]
}