Viktor Malyi
Viktor Malyi

Reputation: 2386

Alternative to application:handleIntent:completionHandler: on WatchOS

iOS's [application:handleIntent:completionHandler:] allows to handle SiriKit intents inside of AppDelegate class on iOS targets.

I wonder whether there is an alternative for this method on WatchOS target as well? What I need is the similar function which handles SiriKit requests on WatchOS and responds to WatchOS intention extension with a result of type INIntentResponse – the same way as it works on iOS.

Thanks in advance!

Upvotes: 0

Views: 212

Answers (1)

Viktor Malyi
Viktor Malyi

Reputation: 2386

It turned out that such method is present in WKExtensionDelegate in WatchOS 5.0+: handleIntent:completionHandler:

Here is an example:

func handle(_ intent: INIntent, completionHandler: @escaping (INIntentResponse) -> Void) {
    let result = INStartWorkoutIntentResponse(code: .ready, userActivity: nil)

    completionHandler(result)
}

Upvotes: 1

Related Questions