iOS 16 - How to include more than 1 AppIntent / AppShortcut

167 views Asked by At

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 tried including ShortcutsTwo's AppShortcut(intent:, phrases) in 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?

1

There are 1 answers

0
Koa On BEST ANSWER

OK, I’ve found 2 things of interest.

  1. You CAN define 2 AppShortcuts(intent:) - but they CAN NOT have []s around them nor commas separating them:
static var appShortcuts: [AppShortcut] {
  AppShortcut(intent:IntentOne(), phrases: [“phrase 1”])
  AppShortcut(intent:IntentTwo(), phrases: [“phrase 2”])
}
  1. While developing, other devices that are listening to Siri but which do NOT have the current AppShortcuts defined will royally mess with your head. Turn off other devices until you’ve finished debugging your AppIntents!