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)optional func application(_ application: UIApplication, handle intent: INIntent) async -> INIntentResponseParameters
- application:
The shared app object.
- intent:
The intent object that contains information about the SiriKit request. Use this object to identify what the user intends 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 delivered. For example, if the
intentparameter contains an Instartworkoutintent object, you must create an Instartworkoutintentresponse object. This parameter must not benil.
Discussion
With this method, an app can handle an intent directly, rather than handling it in the app’s Intent extension. You might use this method to implement workflows that you can’t implement easily in your extension. For example, you might use it to start or manage a user’s workout session. If your app isn’t 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’s handler(for:) method must create a response object that resolves and confirms the intent details. In the response object’s handle(intent:completion:) implementation, return a response object with a status code of failureRequiringAppLaunch. Upon receiving your response, SiriKit launches the app and calls application(_:handle:completionHandler:). In your implementation of this app delegate method, handle the intent by performing the user’s intended action if possible. Then call the provided completion handler with a response object that indicates if your app performed the intent or provides a reason it could not. For details about how to handle a specific intent, see the class reference for that intent in SiriKit.
See Also
Deprecated
application(_:didRegister:)application(_:didReceive:)application(_:didReceiveRemoteNotification:)application(_:handleActionWithIdentifier:for:completionHandler:)application(_:handleActionWithIdentifier:for:withResponseInfo:completionHandler:)application(_:handleActionWithIdentifier:forRemoteNotification:completionHandler:)application(_:handleActionWithIdentifier:forRemoteNotification:withResponseInfo:completionHandler:)application(_:handleOpen:)application(_:open:sourceApplication:annotation:)application(_:willChangeStatusBarOrientation:duration:)application(_:didChangeStatusBarOrientation:)application(_:willChangeStatusBarFrame:)application(_:didChangeStatusBarFrame:)application(_:performFetchWithCompletionHandler:)application(_:shouldSaveApplicationState:)