Introduction to Siri Shortcuts

Posted by Den on June 13, 2018 · 6 mins read

Introduction to Siri Shortcuts

WWDC 2018

Introduction to Siri Shortcuts

WWDC 2018

Creating Shortcuts

  • Define (What you want expose)
  • Donate (Tell the system every time the user does something)
  • Handle
3 steps

Shortcut APIs

NSUserActivity

Define a shortcut ( Info.plist )
Donate a shortcut
Handle a shortcut

Intents

File → New file → SiriKit Intent Definition File

SiriKit Intent Definition File (Custom)

Code generation (Automatically)

Intent Class, IntentHandling Protocol

Donate

Donate your shortcut

Handle

Handle your shortcut

Handle your shortcut in the Background

Intents Extension for your shortcut in the background
Handle your shortcut

INRelevantShortcut

Expose Shortcuts to the Siri Watch Face

How is a Shortcut Suggested?

Shortcut Suggestion Procces
requiredUserInfoKeys
suggestion making process

Custom Intents

  • Use enums (clearly bounded)
  • Custom” results in an INObject
  • Combines an identifier with a display string
  • Identifier can reference an internal object
  • Display string conveys that object to the user
  • Prevents possible implicit dependencies between parameters
Best Practice

Shortcut Display

(title, subtitle, image)

  • Understandable
  • Represent what will happen

Shortcut Testing

Shortcuts Testing in Settings
Xcode Scheme
Shortcut App

Deleting Donations

Deleting user activities (Core Spotlight)
Deleting UserActivity using persistent identifier (new)
Deleting the donation

Play Media Intent

  • INPlayMediaIntent (new)