I am getting An unknown error occurred.
when I tap on parameter which is dynamically provide in my shortcut inside Apples Shortcut app. And the handle(intent: TestIntent) async -> TestIntentResponse
is not getting called.
Implemented the Handing protocol provided and generated by Xcode.
class SiriKitAppClosingIntentHandler: NSObject, LogAppClosingIntentHandling {
func provideAppOptionsCollection(for intent: LogAppClosingIntent, searchTerm: String?) async throws -> INObjectCollection<SiriKitIntentAppName> {
let appOptionsCollection = AppName.appOptionsCollection
if let searchTerm = searchTerm, !searchTerm.isEmpty {
return INObjectCollection(items: appOptionsCollection.filter({ $0.displayString.contains(searchTerm) }))
} else {
return INObjectCollection(items: appOptionsCollection)
}
}
func handle(intent: LogAppClosingIntent) async -> LogAppClosingIntentResponse {
print(" closing intent \(intent) \(#file) \(#line)")
return LogAppClosingIntentResponse(code: .success, userActivity: nil)
}
}
Main reason is not wiring up everything together correctly. Here are the brief intro and the check lists.
SiriKit needs a handler that conforms to the corresponding intent handling protocol.
Each intent object has an associated protocol based on the name of the intent. Ex: <IntentName>IntentHandling
(Intent name: given in the SiriKit intent definition). And this protocol is created by Xcode (If you cant find it you need to build your app after you add one of your intent in the intent definition file)
The protocol defines the methods that your handler implements to resolve any intent parameters and to let SiriKit know how your app handled the intent.
There are two way that you can let Sirikit know your handler that you conform to <IntentName>IntentHandling
protocol.
Implement <IntentName>IntentHandling
protocol
Return 3) implemented class in the handler method in the extension.
Make sure your intent is included in the plist file of the extension under IntentsSupported
. (otherwise add <Name Of The Intent>Intent
)
Implement <IntentName>IntentHandling
protocol
In an iOS app or an app built with Mac Catalyst, implement application(_:handlerFor:)
on your UIApplicationDelegate
.
If you’re using SwiftUI, use UIApplicationDelegateAdaptor
Intents eligible for in-app handling
. (otherwise add <Name Of The Intent>Intent
)