Reputation: 31
I have two intents that I am trying to run using Shortcuts app.
This is the tests I have ran in IntentHandler
:
This works:
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any? {
guard intent is CarIDIntent else {
return .none
}
return AccessTokenIntentHandler()
}
}
This works:
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any? {
guard intent is AccessTokenIntent else {
return .none
}
return AccessTokenIntentHandler()
}
}
This does not work:
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any? {
guard intent is AccessTokenIntent else {
return .none
}
guard intent is CarIDIntent else {
return .none
}
return AccessTokenIntentHandler()
}
}
What am I doing wrong here? Both of them are added to the Intents.intentdefinition
file.
Upvotes: 0
Views: 214
Reputation: 1414
You could try using a switch case, but since you haven't given any information about what the error tells you it's hard to find a exact solution. Try this:
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any? {
switch intent {
case is AccessTokenIntent:
print("Access Token")
case is CarIDIntent:
print("Car ID")
default:
return .none
}
return AccessTokenIntentHandler()
}
}
Upvotes: 1