Instance Method

application(_:handle:completionHandler:)

Asks the delegate to handle the specified SiriKit intent directly.

Declaration

optional func application(_ application: UIApplication, handle intent: INIntent, completionHandler: @escaping (INIntentResponse) -> Void)

Parameters

application

The shared app object.

intent

The intent object that contains information about the SiriKit request. Use this object to identify what the user is trying to do and what kind of response to provide.

completionHandler

The handler block to execute with your response. You must execute this handler at some point during your implementation of this method. This handler has no return value and takes the following parameter:

intentResponse

The response object you create to report the status of the request. The exact type of this object must correspond to the type of intent that was delivered. For example, if the intent parameter contains an INStartWorkoutIntent object, you must create an INStartWorkoutIntentResponse object. This parameter must not be nil.

Discussion

An app with an Intents app extension can use this method to handle an intent directly, instead of handling it in the app extension. You might use this method to implement workflows that you cannot implement easily in your extension. For example, you might use it to start or manage a user's workout session. If your app is not running, SiriKit launches your app in the background so that the Siri interface remains active.

Your Intents app extension is still responsible for resolving and confirming the intent details. Your extension must also handle the intent minimally by creating a response object that indicates the app should handle the intent. Upon receiving your response, SiriKit launches the app as needed and calling this method.In your implementation of this method, handle the intent, generate an appropriate response object, and call the provided completion handler. For details about how to handle a specific intent, see the class reference for that intent in SiriKit.