5

I am trying to implement voice interaction on iOS with SwiftUI and Siri. I am just trying to get a shortcut to work with a single string parameter. I am very new to the framework and have been stuck. Below is what I tried:

  • Started on the Scrumdinger project (from an Apple SwiftUI tutorial, which I have in a GitHub repo. I stopped at commit 90731 before any Siri updates)
  • Created a button to add a Siri shortcut based on NSUserActivity to create a new scrum, but without any parameters; this worked (d64133)
  • Afterwards, I tried a bunch of things that didn't work:
    • Created an intent extension target with a group to share
    • Created an intent with a parameter, naming it "ScrumIntent"
    • Created a shortcut for the intent
    • Requested authorization for Siri

Currently, my set up has all the above and I can create the shortcut, which appears on the shortcuts app. However, it gets stuck and I don't even know how to debug it. If I try voice, Siri complains something went wrong. If I try to click on the shortcut, it is also stuck. Below you can see an image of how it gets stuck, with a stop button almost mid complete.

enter image description here

I am trying to simply set a string in user defaults when the callback gets handled. No special checking on the handler.

Some points about the implementation:

  • The handler is only in the extension target, but I am not sure if that's correct. In SwiftUI we can use the modifier onContinueUserActivity for NSUserActivities, but I couldn't find a similar one for intents (I understood we need intents for parameters).
  • The "Add Siri shortcut" button simply defines the Intent and sets suggestedInvocationPhrase.

Is there any other detail or essential piece of code I should share here? I was not sure so I just shared the github links for now.

Ataias Reis
  • 323
  • 1
  • 9

0 Answers0