I'm having problems donating a custom intent in Xcode 10 (iOS 12 Beta).
I've created a custom framework that's shared between my main app target, and my 'OrderIntent' target.
I've created a .intentdefinition file with the target membership set to my custom framework (screenshot below).
I've embedded an 'Intents Extension' & 'Intents UI Extension' within the main application.
I've also added the 'OrderIntent' to NSExtension->NSExtensionAttributes->IntentsSupported in both of the info.plist files created when I added the intents extensions (screenshot below).
I'm trying to donate the intent like this:
INPreferences.requestSiriAuthorization { (status) in
if status != INSiriAuthorizationStatus.authorized {return}
let orderIntent = OrderIntent()
orderIntent.product = "Test product"
orderIntent.quantity = 2
let interaction = INInteraction(intent: customIntent, response: nil)
interaction.donate { (error) in
if error != nil {2
if let error = error as NSError? {
print(error)
}
} else {
print("success")
}
}
}
The above code runs when a user taps on a button in the app.
I've also set up the intent handler like this:
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
switch intent {
case is OrderIntent:
return OrderIntentHandler()
default:
fatalError()
}
return self
}
And the OrderIntentHandler like this:
public class OrderIntentHandler: NSObject, OrderIntentHandling {
public func handle(intent: OrderIntent, completion: @escaping (OrderIntentResponse) -> Void) {
let orderIntentResponse = OrderIntentResponse(code: OrderIntentResponseCode.success, userActivity: nil)
completion(orderIntentResponse)
}
public func confirm(intent: OrderIntent, completion: @escaping (OrderIntentResponse) -> Void) {
let response = OrderIntentResponse(code: OrderIntentResponseCode.ready, userActivity: nil)
completion(response)
}
}
When testing this on a device, I get the following error:
Error Domain=IntentsErrorDomain Code=1901 "Donating intent 'OrderIntent' is not supported by this application. Please make sure that you have an extension that supports this intent." UserInfo={NSLocalizedDescription=Donating intent 'OrderIntent' is not supported by this application. Please make sure that you have an extension that supports this intent.}
I can't understand why the 'OrderIntent' is not supported by the application.
I've already enabled Siri in the capabilities tab and requested permission from the user etc.
Are there any other steps that need to be taken to allow me to donate the intent?