Main image of article Siri Shortcuts on iOS 12: What Developers Need to Know
Siri Shortcuts are coming to iOS 12, adding a deep layer of utility and complexity to Apple’s voice-activated digital assistant. Users will have their hands full with the "new" Siri, and developers also have a few key takeaways to keep in mind. Siri Shortcuts come down to a simple mantra: keep things simple. They allow users to make just about any in-app function a voice-activated shortcut. That means they can do things such as order coffee, or discover new Tweets from a trusted(?) source, via their voice. Apple suggests developers make simpler actions available to Siri, replete with user-defined calls to action. When a user says “coffee time,” Siri should be able to surface their favorite coffee drink in the app and auto-order it at the local coffee shop. As a result, developers must start adopting APIs. NSUserActivity represents an app’s state, and integrates with other Apple features such as Spotlight and Handoff. It’s here developers will define a shortcut (in the above example: identifying the voice command, surfacing a favorite drink, deciding on the nearest location for pickup, confirming the order with the user, sending the order through a payment queue, and completing the online order), which starts with a UserActivityType declaration in the app’s Info.plist section. A second critical point is the new isEligibleForPrediction flag, which turns actions into shortcuts. This is where developers have the opportunity to define what can and can’t be done via the app. You wouldn’t want Siri to be able to announce to the world how much credit the user has on their loyalty card, and you wouldn’t want the user to have the ability to accidentally replicate a massive order they produced two weeks ago when they graciously bought their entire team coffee. To prevent Siri Shortcuts from getting too involved, Apple has limited the number of ‘types’ each shortcut can perform to 16; each step in our coffee ordering shortcut above is a ‘type,’ save for the command itself. This is a measure to keep users from wasting time asking silly questions such as ‘tell me the temperature for every city in California,’ which would require a unique check for each city. [caption id="attachment_137343" align="aligncenter" width="654"] Apple's Siri digital assistant on macOS[/caption]   Apple also advises that background execution should be toggled on. In a WWDC 2018 session titled ‘Introduction to Siri Shortcuts,’ Apple pointed out that background availability is critical, as it encourages the user to use shortcuts more frequently. Siri Shortcuts must also be ‘donated,’ which is a cute way of saying they are discoverable to users via Siri. Donated shortcuts can also be dynamic; you can define a ‘last order’ repeater if you like, though that can be dangerous (as we noted above). A shortcut could also surface the last few orders on-screen to allow the user to decide what is best. Though voice-first, Siri has an on-screen presence. Siri Shortcuts can not only return confirmation phrases like “great, your order has been placed,” but widgets that allow a user to see a picture of their order, or get walking directions to the place it’s being made. Siri also has its own app with iOS 12: Shortcuts. It’s undeniably a spin on the Apple-purchased Workflow service, which presents Siri Shortcuts in an App Store-esque setting. Shortcuts are currently viewed as gradient tiles, though there’s clearly a ton of room for improvement, here. Finally, Apple cautions developers not to replicate existing Siri Domains and/or Intents. Your fancy note-taking app might be leaps and bounds better than Apple Notes, but adding to a list won’t require a dedicated Siri Shortcut. Instead, Apple advises developers to tap into the existing Intent for that functionality via its API. We’ve long been critical of Siri’s capabilities for end-users, and the SiriKit domains and intents seemed a half-step towards more. At WWDC 2018, Apple gave us more. Initially, it seemed like Apple opened the floodgates for Siri, but closer inspection tells us developers are still in total control. iOS 12 is set to launch this Fall, and all signs point to a mid-September launch for it, as well as the newest iPhones and iPads. That’s not a lot of time, but Siri Shortcuts aren’t terribly difficult to implement, so there’s still time to capture some launch-day synergy.