IntentHandler Class :
import Intents
class IntentHandler: INExtension, INStartWorkoutIntentHandling {
public func handle(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartWorkoutIntent.self))
let response = INStartWorkoutIntentResponse(code: .continueInApp, userActivity: userActivity)
completion(response)
}
func confirm(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void) {
completion(INStartWorkoutIntentResponse(code: .continueInApp, userActivity: nil))
}
}
Apple's documentation says:

Siri opens the application, but I need to display the user interface from IntentUI. How to do it?
In other words: How to prepare for displaying the response, download the UI extension, prepare the interface and display it in code?

IntentViewController Class :
import IntentsUI
class IntentViewController: UIViewController, INUIHostedViewControlling {
func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) {
if let completion = completion {
completion(self.desiredSize)
}
}
var desiredSize: CGSize {
return self.extensionContext!.hostedViewMaximumAllowedSize
}
}
The base for this tutorial is really possible.

source
share