This website uses cookies to better the user experience of its visitors. Where applicable, this website uses a cookie control system, allowing users to allow or disallow the use of cookies on their computer/device on their first visit to the website. This complies with recent legislative requirements for websites to obtain explicit consent from users before leaving behind or reading files such as cookies on a user’s computer/device. To learn more click Cookie Policy.

Privacy preference center

Cookies are small files saved to a user’s computer/device hard drive that track, save, and store information about the user’s interactions and website use. They allow a website, through its server, to provide users with a tailored experience within the site. Users are advised to take necessary steps within their web browser security settings to block all cookies from this website and its external serving vendors if they wish to deny the use and saving of cookies from this website to their computer’s/device’s hard drive. To learn more click Cookie Policy.

Manage consent preferences

These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
Cookies list
Name _rg_session
Provider rubygarage.org
Retention period 2 days
Type First party
Category Necessary
Description The website session cookie is set by the server to maintain the user's session state across different pages of the website. This cookie is essential for functionalities such as login persistence, ensuring a seamless and consistent user experience. The session cookie does not store personal data and is typically deleted when the browser is closed, enhancing privacy and security.
Name m
Provider m.stripe.com
Retention period 1 year 1 month
Type Third party
Category Necessary
Description The m cookie is set by Stripe and is used to help assess the risk associated with attempted transactions on the website. This cookie plays a critical role in fraud detection by identifying and analyzing patterns of behavior to distinguish between legitimate users and potentially fraudulent activity. It enhances the security of online transactions, ensuring that only authorized payments are processed while minimizing the risk of fraud.
Name __cf_bm
Provider .pipedrive.com
Retention period 1 hour
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to support Cloudflare Bot Management. This cookie helps to identify and filter requests from bots, enhancing the security and performance of the website. By distinguishing between legitimate users and automated traffic, it ensures that the site remains protected from malicious bots and potential attacks. This functionality is crucial for maintaining the integrity and reliability of the site's operations.
Name _GRECAPTCHA
Provider .recaptcha.net
Retention period 6 months
Type Third party
Category Necessary
Description The _GRECAPTCHA cookie is set by Google reCAPTCHA to ensure that interactions with the website are from legitimate human users and not automated bots. This cookie helps protect forms, login pages, and other interactive elements from spam and abuse by analyzing user behavior. It is essential for the proper functioning of reCAPTCHA, providing a critical layer of security to maintain the integrity and reliability of the site's interactive features.
Name __cf_bm
Provider .calendly.com
Retention period 30 minutes
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to distinguish between humans and bots. This cookie is beneficial for the website as it helps in making valid reports on the use of the website. By identifying and managing automated traffic, it ensures that analytics and performance metrics accurately reflect human user interactions, thereby enhancing site security and performance.
Name __cfruid
Provider .calendly.com
Retention period During session
Type Third party
Category Necessary
Description The __cfruid cookie is associated with websites using Cloudflare services. This cookie is used to identify trusted web traffic and enhance security. It helps Cloudflare manage and filter legitimate traffic from potentially harmful requests, thereby protecting the website from malicious activities such as DDoS attacks and ensuring reliable performance for genuine users.
Name OptanonConsent
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonConsent cookie determines whether the visitor has accepted the cookie consent box, ensuring that the consent box will not be presented again upon re-entry to the site. This cookie helps maintain the user's consent preferences and compliance with privacy regulations by storing information about the categories of cookies the user has consented to and preventing unnecessary repetition of consent requests.
Name OptanonAlertBoxClosed
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonAlertBoxClosed cookie is set after visitors have seen a cookie information notice and, in some cases, only when they actively close the notice. It ensures that the cookie consent message is not shown again to the user, enhancing the user experience by preventing repetitive notifications. This cookie helps manage user preferences and ensures compliance with privacy regulations by recording when the notice has been acknowledged.
Name referrer_user_id
Provider .calendly.com
Retention period 14 days
Type Third party
Category Necessary
Description The referrer_user_id cookie is set by Calendly to support the booking functionality on the website. This cookie helps track the source of referrals to the booking page, enabling Calendly to attribute bookings accurately and enhance the user experience by streamlining the scheduling process. It assists in managing user sessions and preferences during the booking workflow, ensuring efficient and reliable operation.
Name _calendly_session
Provider .calendly.com
Retention period 21 days
Type Third party
Category Necessary
Description The _calendly_session cookie is set by Calendly, a meeting scheduling tool, to enable the meeting scheduler to function within the website. This cookie facilitates the scheduling process by maintaining session information, allowing visitors to book meetings and add events to their calendars seamlessly. It ensures that the scheduling workflow operates smoothly, providing a consistent and reliable user experience.
Name _gat_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _gat_UA-* cookie is a pattern type cookie set by Google Analytics, where the pattern element in the name contains the unique identity number of the Google Analytics account or website it relates to. This cookie is a variation of the _gat cookie and is used to throttle the request rate, limiting the amount of data collected by Google Analytics on high traffic websites. It helps manage the volume of data recorded, ensuring efficient performance and accurate analytics reporting.
Name _ga
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga cookie is set by Google Analytics to calculate visitor, session, and campaign data for the site's analytics reports. It helps track how users interact with the website, providing insights into site usage and performance.
Name _ga_*
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga_* cookie is set by Google Analytics to store and count page views on the website. This cookie helps track the number of visits and interactions with the website, providing valuable data for performance and user behavior analysis. It belongs to the analytics category and plays a crucial role in generating detailed usage reports for site optimization.
Name _gid
Provider rubygarage.org
Retention period 1 day
Type First party
Category Analytics
Description The _gid cookie is set by Google Analytics to store information about how visitors use a website and to create an analytics report on the website's performance. This cookie collects data on visitor behavior, including pages visited, duration of the visit, and interactions with the website, helping site owners understand and improve user experience. It is part of the analytics category and typically expires after 24 hours.
Name _dc_gtm_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _dc_gtm_UA-* cookie is set by Google Analytics to help load the Google Analytics script tag via Google Tag Manager. This cookie facilitates the efficient loading of analytics tools, ensuring that data on user behavior and website performance is accurately collected and reported. It is categorized under analytics and assists in the seamless integration and functioning of Google Analytics on the website.

A Short Tutorial on How to Implement Voice Control Features in iOS Apps Using SiriKit

  • 22518 views
  • 7 min
  • May 23, 2019
Radislav C.

Radislav C.

IOS Developer

Daria R.

Daria R.

Copywriter

Tags:

Share

Voice control is no longer a futuristic technology. It’s a reality. If you’re an iOS developer who wants to keep pace with the times, you need to consider how voice control can enhance your apps and make them more competitive. In this tutorial, we show you how to implement different voice control features using SiriKit for iOS 12.

What is SiriKit?

SiriKit is a set of tools that allow iOS and watchOS apps to work with Siri, a virtual assistant that responds to a user’s voice. Siri helps users perform different tasks using only voice commands, even from the lock screen.

SiriKit lets you connect your app to Siri and use it even when the app isn’t open. This is possible if the app registers an extension with certain domains and intents that it can process. For example, an app for message communication will support the Message domain and the intent to send a message. Siri processes all interactions with a user and works with an extension for processing user queries.

SiriKit supports two types of extensions:

  • An Intents app extension receives user requests from SiriKit and transforms them into app-specific actions. A user can ask Siri to book a flight, for instance.
  • An Intents UI app extension displays content in the Siri interface after your Intents app extension complies with a user request.

Developers have access to the following domains:

  • Lists. Create reminders, update to-do lists, and check shopping lists.
  • Visual codes. Display QR codes that can be scanned with other devices.
  • Ride booking. Allow users to book a ride and get a report about its status.
  • Messaging. Send text messages.
  • Photo search. Allow users to search for images and videos by content type and play a slideshow.
  • Payments. Allow users to send and request payments.
  • VoIP calling. Perform video and audio calls.
  • Workouts. Allow users to start, pause, and finish routines.
  • Climate and radio. Designed especially for the CarPlay system, this domain allows users to set up climate control and radio.
  • Restaurant reservations. Allow users to create and manage restaurant reservations.

What’s new in SiriKit for iOS 12?

The main update with the new version of SiriKit is a shortcuts feature. Shortcuts allow users to quickly perform various tasks in the app from the lock and search screens and from the Siri watch face. The Shortcuts app allows users to create their own custom shortcuts and activate them with their voice.

Siri learns about new shortcuts via donations, which are released when a user performs an action in an app. How does it work? When a user orders something online, the app makes a donation for a quick order. Siri then decides when to offer shortcuts based on the frequency of donations, the user’s location, the current time, and other parameters.

There are two objects that an app can use to make donations:

  • NSUserActivity – Donates a shortcut using a user activity, which involves viewing specific content in an app.
  • INInteraction – Donates a shortcut using an interaction when the action involves a task that a user has accomplished with the app.

The task

In this tutorial, we’re going to create a fitness app with a customized user interface that will respond to voice commands using SiriKit to start and finish a session. We’ll also add a nutrition ordering feature using Siri Shortcuts.

Step-by-step tutorial

Let’s start with implementing voice commands using SiriKit to start and finish a workout in our fitness app.

Step 1. Integrate SiriKit

Step 1.1. Create an Intents Extension target and implement a handler to start a workout

First of all, we need to create a target of the Intents Extension type. Then in the Intents Extension target, we need to create a class that adopts the INStartWorkoutIntentHandling protocol. We have to implement the method func handle(intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void), which has to return a final response after resolving all necessary values. This protocol allows us to add and resolve such values as the name of a workout and its purpose (for instance, 5 miles, 15 minutes, 100 kilocalories). All the other protocol methods are optional; they resolve values that depend on a domain.

Step 1.2. Implement a handler to finish the workout

Now it’s time to create a class that adopts the INEndWorkoutIntentHandling protocol and implements a method that has to return a response: func handle(intent: INEndWorkoutIntent, completion: @escaping (INEndWorkoutIntentResponse) -> Void) in the Intents Extension target.

Step 1.3. Determine handlers in the Intent Handler

Now, let’s override the func handler(for intent: INIntent) -> Any? method in the Intents Extension target in the IntentHandler class to determine what class handler is going to be used for the relevant intent.

Step 1.4. Authorize Siri and process intents in the application

Let’s implement the func application(_ application: UIApplication, handle intent: INIntent, completionHandler: @escaping (INIntentResponse) -> Void) method in the AppDelegate class to process a certain intent in the app launched after an interaction with Siri. To use Siri, we need to add an authorization query to the file.

Step 1.5. Use the intent instance to get values from a user

Implement the public static func start(with intent: INStartWorkoutIntent) method in the shared core target in the class WorkoutService. This will start a workout using data from the intent.

Below, you can see the results of implementing the voice command in our app.

SiriKit tutorial
Siri Shortcuts implementation

Step 2. Implementing Siri Shortcuts

It’s time to implement a nutrition ordering feature using Siri Shortcuts.

Step 2.1. Create Intent Definition file

Create Intent Definition file in the shared core target. In this file, we need to create a customized intent with a certain category, parameters, and types of shortcuts.

ios 12 sirikit tutorial
Custom intent

Step 2.2. Implement a handler for product ordering

Create a class that adopts the OrderProductIntentHandling protocol in the Intents Extension target.

Step 2.3. Determine the handler in Intent Handler

Now, we need to override the func handler(for intent: INIntent) -> Any? method in the Intents Extension target in the IntentHandler class. That’s how we’ll find out what class handler will be used for the relevant intent.

Step 2.4. Donate an order to Siri

We also need to implement the private static func donate(_ order: Order) method in the shared core target. This method will donate after successfully placing an order.

Step 2.5. Create Intents Extension UI target and implement a custom UI

The next step is to create an Intents Extension UI target. Then implement your customized UI in the Intents Extension UI target, in the file MainInterface.storyboard. After that, implement the logic of displaying order's data in the IntentViewController class.

You can see the results of implementing Siri Shortcuts in the screenshots below.

SiriKit12
Voice command implementation

Wrapping up

SiriKit is a unique toolset that allows you to easily implement voice control features in your iOS apps. We hope that this tutorial has helped you improve your skills and hope we’ll see a lot of great projects based on SiriKit from you soon.

Check the source code of this tutorial and don’t hesitate to start a conversation below if you have any questions. Don’t forget to subscribe to our blog to get more detailed tutorials from us!

CONTENTS

Tags:

Authors:

Radislav C.

Radislav C.

IOS Developer

Daria R.

Daria R.

Copywriter

Rate this article!

Nay
So-so
Not bad
Good
Wow
2 rating, average 4.5 out of 5

Share article with

Comments (0)

There are no comments yet

Leave a comment

Subscribe via email and know it all first!