cokamotka
cokamotka

Reputation: 105

How to have both Siri response and custom Siri UI View in one Siri Shortcut?

I implemented Siri Shortcuts in my app as well as Siri Custom UI handling and everything works as expected.

What I'm trying to achieve now is to use both Siri Intent Response, and Siri UI response when handling the intent. Let's say that the example would be:

  1. Siri UI View: There are 10 out of 100 cars parked. Bla, bla...
  2. Siri Response: "There are 90 available car spots."

So, in my Intent Handler I can use:

func handle(intent: MyIntent, completion: @escaping (MyIntentResponse) -> Void) {

    let userActivity...

    completion(MyIntentResponse(code: .success, userActivity: userActivity))
}

to show custom UI View, or I can use:

func handle(intent: MyIntent, completion: @escaping (MyIntentResponse) -> Void) {

    completion(.success(customIntParameter: 90))
}

to let Siri speak the sentence provided in Intent response with my custom Int parameter.

Now, I'm wondering if there is a way to show my custom UI and make Siri speak the response. Basically to use both of these completion somehow. Any ideas?

I wouldn't like to use some text-to-speech speaking solutions, but use native Siri response.

Upvotes: 0

Views: 123

Answers (1)

cokamotka
cokamotka

Reputation: 105

Ok, found it!

func handle(intent: MyIntent, completion: @escaping (MyIntentResponse) -> Void) {

    let userActivity...
    let response = MyIntentResponse(code: .success, userActivity: userActivity)

    response.customIntParameter = 90

    completion(response)
}

Simple as that.

Upvotes: 0

Related Questions