iOS 16 - how to get more than 1 AppIntents / AppShortcut

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?

Accepted Reply

I've hacked my way into a solution... turns out that:

  1. I only need to call .updateAppShortcutParameters() once
  2. that call to .updateAppShortcutParameters() needs to include an AppShortcut(intent:, phrases:) call for each AppIntent I've written
  3. 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"]
}
  • oh, and this is a funny one: much of what I was perceiving as temperamental behavior was due to my several iPadOS devices - all of whom were set to "Listen for 'Hey Siri'" - with each one trying desperately to out-Siri the others - and most annoyingly my development iPhone! So, my iPhone was the only one with the AppIntents installed - but all my devices were trying to satisfy my "Hey Siri". Arrrrgh! ¯_(ツ)_/¯

Add a Comment

Replies

I've hacked my way into a solution... turns out that:

  1. I only need to call .updateAppShortcutParameters() once
  2. that call to .updateAppShortcutParameters() needs to include an AppShortcut(intent:, phrases:) call for each AppIntent I've written
  3. 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"]
}
  • oh, and this is a funny one: much of what I was perceiving as temperamental behavior was due to my several iPadOS devices - all of whom were set to "Listen for 'Hey Siri'" - with each one trying desperately to out-Siri the others - and most annoyingly my development iPhone! So, my iPhone was the only one with the AppIntents installed - but all my devices were trying to satisfy my "Hey Siri". Arrrrgh! ¯_(ツ)_/¯

Add a Comment