One of the most exciting new features of iOS 10 is that it opens Siri to app developers. In this blog post, we’ll cover the basics of how to add Siri support to your existing apps.
Siri was introduced in 2011 as part of iOS, after Apple acquired Siri’s developers in 2010 and integrated it into the core of iOS as a digital personal assistant which uses natural language patterns to answer questions, make recommendations, and perform actions.
Prior to iOS 10, Siri was unavailable as a separate app on the App Store. However now, with the release of SiriKit, Apple has made it possible to integrate your app’s content and service with Siri. SiriKit supports a number of domains, each of which defines tasks that can be performed, including the following:
- VoIP calling
- Ride booking
- CarPlay (automotive vendors only)
- Restaurant reservations (requires additional support from Apple)
Siri “thinks” of things in Domains, which are broad categories of concepts, such as messaging, VoIP, payment, workouts, ride booking, and photo search. Domains have known actions called Intents, and each Intent has a series of parameters. Before starting with SiriKit, you’ll want to ensure that your app fits into a Domain that Apple supports.
Intents and Intents UI Extensions
If you’ve ever developed for Apple Maps, you’ll already be familiar with developing App Extensions using Intents. There are two types of App Extensions used to interact with Siri:
- Intents Extension: Provides Siri and Maps with the app’s content and performs the tasks required to fulfill any supported intents.
- Intents UI Extension: Provides a custom UI that will be displayed for the app’s content inside of either Siri or Maps.
It’s essential that your app provides an Intents Extension to support SiriKit, but you can opt out of providing a UI Extension since Siri can handle all user interaction using the standard, built-in UI. The Intent Extension can support one or more Intents; it’s up to you to decide how you want to implement Siri in your apps, as there are a number of ways to accomplish it. With that said, Apple has requested that we as developers try to limit the number of Intent Extensions, as this will help keep memory usage down and increase Siri’s performance.
If we take a simple use case, in this instance adding Siri support to a messaging app, the user might interact with Siri with the follow conversation.
|“Hey Siri, send a XamarinChat Message”|
|“What do you want to say to Miguel?”|
|“Good job on creating Mono”|
The process of turning this conversation into an actionable item looks like this:
- Siri takes the audio of the user’s Speech and converts it into text.
- The text is converted into an Intent, a structured representation of the user’s request.
- Based on the Intent, Siri will take Action to perform the user’s request.
- Finally, Siri will present Responses (both visual and verbal) to the user based on the Action taken.
Privacy and Security Considerations
Privacy and security was touted as one of the main features of iOS 10 and Apple has taken Siri’s security very seriously. They have ensured that private information remains secure when working with Siri and have marked particular interactions as requiring the device to be unlocked, for example, requesting a car through Uber or Lyft or making a payment.
You might also want to ensure that the user has unlocked the device before allowing your Siri extension to be used. This is easy to include by adding Restrict While Locked to your apps Info.plist.
SiriKit is a huge addition to iOS 10, with lots of options for developers to use to implement it into our apps. If you’re looking for more information, you’ll find an in-depth review of the new APIs in our documentation as well as a complete sample project on our GitHub.