Chapter 2. SiriKit
Siri has been an integral part of iOS since Apple bought this technology and integrated it with the iPhone in 2011. However, Siri has been a closed technology up to now, and developers like you and me were not able to provide our own extensions.
iOS 10 has changed this situation. Now you can add your own extensions to Siri and allow users to interact with your apps and the services inside your apps, through Siri.
Imagine that you have a financial app that allows users to send up to $20 worth of money to family and friends using their telephone numbers. The user can say, for instance, “Send 15 dollars to Max.” Then your app looks in the user’s address book to determine whether there is a contact called “Max” listed. If there is, you allow the financial transaction to go through. There are a few steps that you have to take in order to make your app Siri compatible, and we will have a look at those first.
2.1 Setting Up Your Project for Siri
Problem
You want to enable interactions with Siri in your app.
Solution
Follow these steps, the details of which can be found in this recipe’s Discussion:
- Create your app, if you don’t already have one.
- Enable Siri capabilities in your target’s preferences in Xcode.
- Add an Intents extension to your app as a new target.
- Define your intents in the extension’s info.plist file.
- In your app’s info.plist file, define the
NSSiriUsageDescription
key, along with a message explaining why you are intending to use Siri in your application. ...
Get iOS 10 Swift Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.