SlideShare a Scribd company logo
1 of 27
Download to read offline
Say Hello
to Siri !
Snehal Patil – iOS Developer @ Yahoo
Only Supported Domains !
•  VoIP calling
•  Messaging
•  Payments
•  Photo
•  Workouts
•  Ride booking
•  CarPlay (automotive vendors only)
•  Restaurant reservations (requires
additional support from Apple)
So before you go and start
thinking about all the
different potential use
cases for your app, keep
in mind that Apple has
only opened support for
these six domains.
!
2 new Frameworks
Siri Kit was introduced in WWDC 2016,
giving users the ability to control your
app’s behavior using their voice.
Intents framework - communication
between your app and the system.
Intents UI framework - presenting a
custom interface when one of your tasks
is performed.
Siri Workflow
1.  First, Siri takes the audio of the user's Speech and converts it into text.
2.  Next, the text is converted into an Intent, a structured representation of the
user's request.
3.  Based on the Intent, Siri will take Action to perform the user's request.
4.  Finally, Siri will present Responses (both visual and verbal) to the user based
on the Action taken.
Speech Intent Action Response
Siri + App Workflow
1.  Vocabulary - This is how the app tells Siri the words it needs to know to interact with it.
2.  App Logic - These are the actions and responses that the app will take based on given Intents.
3.  User Interface - This is the optional, custom user interface that the app can give its responses in.
Speech Intent Action Response
Vocabulary App Logic
User
Interface
Intent Object - Messaging Domain
The structured Intent will contain the following information:
Domain: Messages
Intent: sendMessage
Recipient: John
Content: lets go!
INSendMessageIntentRespon
seCode - unspecified, ready,
Inprogress, success, failure,
failureRequiringAppLaunch,
failureMessageServiceNotAvaila
ble
NSUserActivity
INSendMessageIntent INSendMessageIntentResponse
The Intent Lifecycle
1.  The app must Resolve every parameter on an event. As a result, the app will call Resolve multiple times (once
per each parameter), and sometimes multiple times on the same parameter until the app and the user agree
on what is being requested.
2.  The app must Confirm that it can handle the requested Intent and tell Siri about the expected outcome.
3.  Finally, the app must Handle the Intent and perform the steps to achieve the requested outcome.
The Intent Extension
●  The Intents Extension is responsible for handling the main interactions between the app and Siri
●  Implements resolve, confirms and handle results
●  Support one or more intents - choose as per your apps requirements
●  Runs in the background while Siri is in foreground
●  Security can be handled by - restricting access while device is locked locked and by asking
permission - for ex, dont allow user to send payments when app is locked.
Intent Methods - Messaging Domain
Resolve
func resolveRecipients(forSendMessage intent: INSendMessageIntent, with completion:
([INPersonResolutionResult]) -> Swift.Void) {
}
Resolve response
Success(with:)
Your app matched the user's request
ConfirmationRequired(with:)
Siri makes sure about users request
Disambiguation(with:)
Your app needs the user to select from a list of people
provide options to choose from
Confirm
func confirm(sendMessage intent: INSendMessageIntent, completion: @escaping
(INSendMessageIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType:
NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .ready, userActivity: userActivity)
completion(response)
}
•  Tell Siri the expected result of an intent using intent response
•  Siri prompts for confirmation using NSUserActivity
Handle
func handle(sendMessage intent: INSendMessageIntent, completion: @escaping
(INSendMessageIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType:
NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity)
completion(response)
}
•  Perform the requested action
•  Provide as much info about the result as possible
•  Provide response in few seconds, otherwise use inprogress intent (for ex, network call)
Intent UI Extension
•  Bring your apps interface into siri ( for ex. Brand, visual
identity)
•  Provide a UIViewcontroller - which can be customized
•  Completely Optional
•  Displayed alongside siri content
•  Not interactive - you can’t put "controls" in your UI intent
interface.
Creating Intent Extension
Extensions
Siri Entitlement
Configuration plist
NSExtension
NSExtensionAttributes
IntentsSupported IntentsRestrictedWhile-
Locked (optional)
Requesting Authorization in plist
Include the
NSSiriUsageDescription
key in your iOS app’s
Info.plist file.
Requesting Siri Authorization in Your iOS App
INPreferences.requestSiriAuthorization() { (status) in
print("New status: (status)")
}
Structuring Your App’s Services
Implement your core services in a private shared
framework : A private shared framework lets you
define your core services in one code module
and link the code dynamically into your iOS app
and your Intents extension. Using a framework
minimizes the size of both executables and
ensures that both use the same code.
Use a shared container to store common
resources. Put relevant images and data files
into a shared container so that they can also be
accessed by your Intents extension. You can
enable shared container support in the
Capabilities tab of your iOS app and Intents
extension targets.
Specifying Custom Vocabulary - INVocabulary object
•  Defining custom vocabulary helps Siri understand commands used in conjunction with
your app, which improves the user experience.
•  Choose terms that could be misunderstood by someone not familiar with your app.
•  Do not register terms that are easily understood, ex. “My Photo Album” or “My
Workout”.
•  Focus on terms whose literal meaning differs from your app’s usage of those terms.
•  The most important terms should always be first in the NSOrderedSet object that you
create.
•  To register terms that are specific to a single user, use the INVocabulary object.
let workoutNames = self.sortedWorkoutNames()
let vocabulary = INVocabular.shared()
vocabulary.setVocabularyStrings(workoutNames, of: .workoutActivityName)
Global Vocabulary file - AppIntentVocabulary.plist
Demo
Limitation
•  Only support few domains. Out of the 2 million apps in the App Store, how many fall under the
support of the six categories? This is the primary downside of the system Apple devised.
•  If you are very excited to add speech recognition into your app which might not fall into supported
Siri kit domain - Try Speech Recognition Framework --
https://realm.io/news/tryswift-marc-brown-say-it-aint-so-implementing-speech-recognition/?
utm_campaign=This%2BWeek%2Bin
%2BSwift&utm_medium=email&utm_source=This_Week_in_Swift_103
Example Code
•  Unicorn Chat - https://developer.apple.com/library/prerelease/content/samplecode/UnicornChat/
Listings/SiriExtension_UCSendMessageIntentHandler_swift.html
Thank you !

More Related Content

Viewers also liked

'The Google Now Adventure'
'The Google Now Adventure''The Google Now Adventure'
'The Google Now Adventure'Kurtis Damerow
 
Introduction to tvOS app Development !
Introduction to tvOS app Development !Introduction to tvOS app Development !
Introduction to tvOS app Development !Snehal Patil
 
Google Voice Presentation
Google Voice PresentationGoogle Voice Presentation
Google Voice Presentationgibs1208
 
Sirikit par Julien Coudsi
Sirikit par Julien CoudsiSirikit par Julien Coudsi
Sirikit par Julien CoudsiIdean France
 

Viewers also liked (7)

'The Google Now Adventure'
'The Google Now Adventure''The Google Now Adventure'
'The Google Now Adventure'
 
Introduction to tvOS app Development !
Introduction to tvOS app Development !Introduction to tvOS app Development !
Introduction to tvOS app Development !
 
Google Voice Presentation
Google Voice PresentationGoogle Voice Presentation
Google Voice Presentation
 
Siri
SiriSiri
Siri
 
Cortana
Cortana Cortana
Cortana
 
How Siri Works
How Siri WorksHow Siri Works
How Siri Works
 
Sirikit par Julien Coudsi
Sirikit par Julien CoudsiSirikit par Julien Coudsi
Sirikit par Julien Coudsi
 

Similar to Learn about iOS10 Siri Kit

Hieu Xamarin iOS9, Android M 3-11-2015
Hieu Xamarin iOS9, Android M  3-11-2015Hieu Xamarin iOS9, Android M  3-11-2015
Hieu Xamarin iOS9, Android M 3-11-2015Nguyen Hieu
 
Beginning android
Beginning android Beginning android
Beginning android Igor R
 
iOS Developer Interview Questions
iOS Developer Interview QuestionsiOS Developer Interview Questions
iOS Developer Interview QuestionsClark Davidson
 
Session 7 - Overview of the iOS7 app development architecture
Session 7 - Overview of the iOS7 app development architectureSession 7 - Overview of the iOS7 app development architecture
Session 7 - Overview of the iOS7 app development architectureVu Tran Lam
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptbharatt7
 
Android_Workshop
Android_WorkshopAndroid_Workshop
Android_WorkshopSenthil ACS
 
Deepak_iOSDeveloper_3.5Exp
Deepak_iOSDeveloper_3.5ExpDeepak_iOSDeveloper_3.5Exp
Deepak_iOSDeveloper_3.5ExpDeepak Bachu
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications developmentAlfredo Morresi
 
How to integrate flurry in android
How to integrate flurry in androidHow to integrate flurry in android
How to integrate flurry in androidadityakumar2080
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Software Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good ArchitectureSoftware Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good Architecturemahmud05
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1Hussain Behestee
 
itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012
itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012
itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012itslearning Nederland
 
20120612 itslearning app library dag
20120612 itslearning app library dag20120612 itslearning app library dag
20120612 itslearning app library dagTim Remmers
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development TutorialGermán Bringas
 

Similar to Learn about iOS10 Siri Kit (20)

Hieu Xamarin iOS9, Android M 3-11-2015
Hieu Xamarin iOS9, Android M  3-11-2015Hieu Xamarin iOS9, Android M  3-11-2015
Hieu Xamarin iOS9, Android M 3-11-2015
 
Beginning android
Beginning android Beginning android
Beginning android
 
RakeshKushwaha
RakeshKushwahaRakeshKushwaha
RakeshKushwaha
 
Mobile Application
Mobile ApplicationMobile Application
Mobile Application
 
iOS Developer Interview Questions
iOS Developer Interview QuestionsiOS Developer Interview Questions
iOS Developer Interview Questions
 
Session 7 - Overview of the iOS7 app development architecture
Session 7 - Overview of the iOS7 app development architectureSession 7 - Overview of the iOS7 app development architecture
Session 7 - Overview of the iOS7 app development architecture
 
SahilaMirajkar
SahilaMirajkarSahilaMirajkar
SahilaMirajkar
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
 
Android_Workshop
Android_WorkshopAndroid_Workshop
Android_Workshop
 
Deepak_iOSDeveloper_3.5Exp
Deepak_iOSDeveloper_3.5ExpDeepak_iOSDeveloper_3.5Exp
Deepak_iOSDeveloper_3.5Exp
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
How to integrate flurry in android
How to integrate flurry in androidHow to integrate flurry in android
How to integrate flurry in android
 
awadhesh online
awadhesh onlineawadhesh online
awadhesh online
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Software Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good ArchitectureSoftware Requirement Analysis and Thinking Process towards a good Architecture
Software Requirement Analysis and Thinking Process towards a good Architecture
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012
itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012
itslearning App Library dag voor partners - Tim Remmers - 12 juni 2012
 
20120612 itslearning app library dag
20120612 itslearning app library dag20120612 itslearning app library dag
20120612 itslearning app library dag
 
Android_ver_01
Android_ver_01Android_ver_01
Android_ver_01
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 

Recently uploaded

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 

Recently uploaded (20)

(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Learn about iOS10 Siri Kit

  • 1. Say Hello to Siri ! Snehal Patil – iOS Developer @ Yahoo
  • 2.
  • 3. Only Supported Domains ! •  VoIP calling •  Messaging •  Payments •  Photo •  Workouts •  Ride booking •  CarPlay (automotive vendors only) •  Restaurant reservations (requires additional support from Apple) So before you go and start thinking about all the different potential use cases for your app, keep in mind that Apple has only opened support for these six domains. !
  • 4. 2 new Frameworks Siri Kit was introduced in WWDC 2016, giving users the ability to control your app’s behavior using their voice. Intents framework - communication between your app and the system. Intents UI framework - presenting a custom interface when one of your tasks is performed.
  • 5. Siri Workflow 1.  First, Siri takes the audio of the user's Speech and converts it into text. 2.  Next, the text is converted into an Intent, a structured representation of the user's request. 3.  Based on the Intent, Siri will take Action to perform the user's request. 4.  Finally, Siri will present Responses (both visual and verbal) to the user based on the Action taken. Speech Intent Action Response
  • 6. Siri + App Workflow 1.  Vocabulary - This is how the app tells Siri the words it needs to know to interact with it. 2.  App Logic - These are the actions and responses that the app will take based on given Intents. 3.  User Interface - This is the optional, custom user interface that the app can give its responses in. Speech Intent Action Response Vocabulary App Logic User Interface
  • 7. Intent Object - Messaging Domain The structured Intent will contain the following information: Domain: Messages Intent: sendMessage Recipient: John Content: lets go! INSendMessageIntentRespon seCode - unspecified, ready, Inprogress, success, failure, failureRequiringAppLaunch, failureMessageServiceNotAvaila ble NSUserActivity INSendMessageIntent INSendMessageIntentResponse
  • 8. The Intent Lifecycle 1.  The app must Resolve every parameter on an event. As a result, the app will call Resolve multiple times (once per each parameter), and sometimes multiple times on the same parameter until the app and the user agree on what is being requested. 2.  The app must Confirm that it can handle the requested Intent and tell Siri about the expected outcome. 3.  Finally, the app must Handle the Intent and perform the steps to achieve the requested outcome.
  • 9. The Intent Extension ●  The Intents Extension is responsible for handling the main interactions between the app and Siri ●  Implements resolve, confirms and handle results ●  Support one or more intents - choose as per your apps requirements ●  Runs in the background while Siri is in foreground ●  Security can be handled by - restricting access while device is locked locked and by asking permission - for ex, dont allow user to send payments when app is locked.
  • 10. Intent Methods - Messaging Domain
  • 11. Resolve func resolveRecipients(forSendMessage intent: INSendMessageIntent, with completion: ([INPersonResolutionResult]) -> Swift.Void) { } Resolve response Success(with:) Your app matched the user's request ConfirmationRequired(with:) Siri makes sure about users request Disambiguation(with:) Your app needs the user to select from a list of people provide options to choose from
  • 12. Confirm func confirm(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) { let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self)) let response = INSendMessageIntentResponse(code: .ready, userActivity: userActivity) completion(response) } •  Tell Siri the expected result of an intent using intent response •  Siri prompts for confirmation using NSUserActivity
  • 13. Handle func handle(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) { let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self)) let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity) completion(response) } •  Perform the requested action •  Provide as much info about the result as possible •  Provide response in few seconds, otherwise use inprogress intent (for ex, network call)
  • 14. Intent UI Extension •  Bring your apps interface into siri ( for ex. Brand, visual identity) •  Provide a UIViewcontroller - which can be customized •  Completely Optional •  Displayed alongside siri content •  Not interactive - you can’t put "controls" in your UI intent interface.
  • 19. Requesting Authorization in plist Include the NSSiriUsageDescription key in your iOS app’s Info.plist file.
  • 20. Requesting Siri Authorization in Your iOS App INPreferences.requestSiriAuthorization() { (status) in print("New status: (status)") }
  • 21. Structuring Your App’s Services Implement your core services in a private shared framework : A private shared framework lets you define your core services in one code module and link the code dynamically into your iOS app and your Intents extension. Using a framework minimizes the size of both executables and ensures that both use the same code. Use a shared container to store common resources. Put relevant images and data files into a shared container so that they can also be accessed by your Intents extension. You can enable shared container support in the Capabilities tab of your iOS app and Intents extension targets.
  • 22. Specifying Custom Vocabulary - INVocabulary object •  Defining custom vocabulary helps Siri understand commands used in conjunction with your app, which improves the user experience. •  Choose terms that could be misunderstood by someone not familiar with your app. •  Do not register terms that are easily understood, ex. “My Photo Album” or “My Workout”. •  Focus on terms whose literal meaning differs from your app’s usage of those terms. •  The most important terms should always be first in the NSOrderedSet object that you create. •  To register terms that are specific to a single user, use the INVocabulary object. let workoutNames = self.sortedWorkoutNames() let vocabulary = INVocabular.shared() vocabulary.setVocabularyStrings(workoutNames, of: .workoutActivityName)
  • 23. Global Vocabulary file - AppIntentVocabulary.plist
  • 24. Demo
  • 25. Limitation •  Only support few domains. Out of the 2 million apps in the App Store, how many fall under the support of the six categories? This is the primary downside of the system Apple devised. •  If you are very excited to add speech recognition into your app which might not fall into supported Siri kit domain - Try Speech Recognition Framework -- https://realm.io/news/tryswift-marc-brown-say-it-aint-so-implementing-speech-recognition/? utm_campaign=This%2BWeek%2Bin %2BSwift&utm_medium=email&utm_source=This_Week_in_Swift_103
  • 26. Example Code •  Unicorn Chat - https://developer.apple.com/library/prerelease/content/samplecode/UnicornChat/ Listings/SiriExtension_UCSendMessageIntentHandler_swift.html