IntentAction
@available(iOS 12, *)
public protocol IntentAction : IntentBackgroundAction
Adopt this protocol when implementing an action that fulfills a Siri Intent via an Intent Extension
Note
See https://bugs.swift.org/browse/SR-10831 for why this is so ugly re: defaulting the associated types. The type inference should see the constraints fully satisfy the associated types but it doesn’t, so we have to also specify the associatedtype so that conforming types can compile-
The type of the
INIntent
thatt this action will implement. This is the Xcode-generated response type produced from your intent definition configuration.Declaration
Swift
associatedtype IntentType : FlintIntent
-
The type of the
INIntentResponse
for theINIntent
. This is the Xcode-generated response type produced from your intent definition configuration.Declaration
Swift
associatedtype IntentResponseType : FlintIntentResponse where Self.PresenterType == IntentResponsePresenter<Self.IntentResponseType>
-
Set the default presenter type, so our convenient extensions are available
Declaration
Swift
associatedtype PresenterType = IntentResponsePresenter<Self.IntentResponseType>
-
Implement this function if the Action supports a Siri Intent for Shortcuts. This is used to register a shortcut intent with Siri if you have the
IntentShortcutDonationFeature
enabled.This call can throw if the input fails to be converted to an intent and this is important to your app. You can also return nil to simply suppress creation of an intent for the given input.
- param input: The input instance. Read properties of this to create an instance of the intent type.
- return: The intent that should trigger this action for the given input, or nil to indicate no intent is available
Declaration
Swift
@available(iOS 12, *) static func intent(withInput input: InputType) throws -> IntentType?
-
Implement this function to create a valid input for the action from and instance of the
IntentType
, used when performing the action for an intent.This call can throw if the intent fails to be converted to an input and this is important to your app. You can also return nil to simply suppress creation of an intent for the given input.
- param intent: The intent instance. Read properties of this to create an instance of the input type.
- return: The input to use to perform the action for this intent
Declaration
Swift
@available(iOS 12, *) static func input(fromIntent intent: IntentType) throws -> InputType?