a NSUserActivity object every time user performs an action for which you want to create a shortcut. • Make your NSUserActivity, eligible for Siri Shortcut by a simple flag introduced in iOS 12.0. This will tell Siri that it can suggest this user activity as a shortcut to user.
in Siri, without opening the app. • For creating custom intent, we need to create an Intent Definition file • Intent Definition file is where all custom intents are defined.
to implement the respective handling protocol. • Provide data for parameters whose options are dynamic • Resolve parameters (Getting value for parameters) • Once the parameters are resolved or once we have all the values, we need to handle or complete the intent. • What does handling protocol consists? What are the things that we need to implement?
is required, tell siri that you need value from user • confirmationRequired - siri will ask user for the confirmation of the parameter value • notRequired - value for parameter is not required, move on to the next parameter • success - valid value, move on to next parameter • unsupported - if the value is not supported, tell siri to ask question again • disambiguation - Siri will ask user to choose from the list of values provided with disambiguation. With this, you can provide or change the datasource.
value to the expected parameter Lifecycle of Parameter Resolution Resolve Parmeter A SiriKit 1. Calls resolve initially 2. If value nil call needsValue() 5. Will ask user for the value. Provide Options A 3. For dynamic options 6. Selects or Says the value 8. Checks for the updated value in intent, return appropriate parameter resolution type Resolve Parmeter B 9c. Success or notRequired 9a. Unsupported or Disambiguation Resolution Type 9b. confirmationRequired 9b. If user confirmed
to sirikit. • Create Intent Extension target • Xcode creates a IntentHandler.swift file inside intent extension target for us when the target is created • Intent Handler file is where all intents are handled.
custom UI according to the response code we return. • To show our custom UI, we need to create a new target - IntentUIExtension • Xcode automatically generates a view controller class (IntentViewController.swift), where we can add our own child view controller or simply a view. • We can provide different UI for different response codes