Shortcuts

iOS shortcuts

Primitives

Programming Language Components

  • control flow: if, repeat, wait
  • variables: add, get, set, get name, get type, set name, list
  • math: calculate, random number

Generic primitives

Examples

  • HTTP methods (get/post/put/patch/delete)
  • Dictionary operation (set/get)
  • Run script over SSH
  • x-callback-url (interapp communication)

Primitives for built-in apps

See Google Spreedsheet.

Primitives for third-party apps

Developer can add primitives when they publish an app. There are two different implementation: NSUserActivity and Intent. The former one will open the app and allow users to view or operate inside the app, but it won’t return any value. Developers work around this by copy to clipboard and use “Get clipboard” action. The latter one will just run the function without switching view to the app. However, it does allow customized response.

User Interface

Create

A GUI is used to create shortcuts. A menu with a search bar to select primitives; once a primitive is select, it is added to the flow diagram; user then can fill in slots (type in value, choose value from previous primitives selected, use “shortcut input”or set it as “Ask when Run”)

Activate

There are three major ways to activate:

  • Click the button: click on the button inside the shortcuts app; or you can add shortcuts to your home screen/widgets and click from there
  • Call its name by Siri
  • Through share button: this way, it will pass the shared content as “shortcut input” in String format, and only allow users to choose shortcuts asking for a “shortcut input”

Share

The formal representation is hidden from the users and developers. A unique link will be created for each shortcut, and user can use the shortcut by link directly.