Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Siri and SiriKit: an Intents topic

Given by Alexsander Akers at Swift Alps on 29 Nov. 2018

SiriKit (Apple Documentation)


System Domains

* Requires private entitlement from Apple

Custom Domains

  • Defined in your app through Intents.intentdefinition file
  • Used to repeat a specific action that the user has already performed, or that the app thinks is relevant
  • These intents support parameters, but are "baked into" the intent at the time the shortcut is added
    • For example, you cannot prompt for additional information through Siri, but you can continue a flow in your app

A) Add Siri Shortcuts to your app with NSUserActivity

What is NSUserActivity?

An NSUserActivity is a snapshot of what the user is doing in your app at a moment in time. These activities allow users to hand off their tasks between devices, to search for previously viewed content (e.g. map items), and to allow the system to suggest relevant data from user-initiated activities in your app.

What you will be doing

Donating Shortcuts (Apple Documentation)

  1. Assign NSUserActivity instances to your view controllers (or call the activity's becomeCurrent() method).
  2. Set isEligibleForPrediction on the activity to true.
  3. Optionally set suggestedInvocationPhrase on the activity to show the user with a specific (localized!) as a prompt.
  4. Implement the UIApplicationDelegate method application(_:continue:restorationHandler:)
  5. Use INShortcut to create a shortcut. Then create a INUIAddVoiceShortcutViewController view controller with that shortcut to allow the user to record a invocation phrase for this shortcut.

B) Implement a system domain (see above) in your app

  1. Create a new Intents Extension target in your app.
  2. Add the intent type to your extension's Info.plist file under NSExtension > IntentsSupported or NSExtension > IntentsRestrictedWhileLocked
  3. Modify the template IntentHandler.swift class to initialize handler objects for INIntent types.
  4. Create a CreateTaskListIntentHandler class that conforms to the INCreateTaskListIntentHandling protocol and implement the methods in that protocol to resolve details of the intent, confirm the response, and handle the intent of the user.
  5. Repeat these steps (starting with 2) for each INIntent type you want to support

C) Implement a custom domain in your app

  1. Create a new Intents Extension target in your app.
  2. Create a SiriKit Intent Definition File-type file in your app's shared framework.
  3. Include this file in your app, your app's shared framework, and your app's Intents extension. If your app has an IntentsUI extension, include this file there as well.
  4. Make sure that the Intent Classes option is only selected for your app's shared framework target(s).
  5. Click on the + button to create a new custom intent or to customize an existing system intent.
  6. Select an appropriate Category and specify the Title and Description for your intent.
  7. Follow the steps above to mark your extension as supporting your custom intent as well as to implement the custom intent handler.

D) Implement the Lists domain in MVCTodo

MVCTodo is a sample project by Dave DeLong (modified to remove some of the initial shared framework overhead) that we can use as a basis on which to implement the Siri Lists domain. Follow the steps for Task B for each list- and task-related INIntent type found on the Lists and Notes domain page.



A workshop about Siri and SiriKit from Swift Alps 2018



No releases published


No packages published
You can’t perform that action at this time.