Monday, September 24, 2018

iOS Custom Intents

Custom Intents now allow apps to define their own models for requests and responses to Siri that are specific to actions performed in the app. Now these actions aren’t constrained by Apple’s system domain of intents.

1. First task is to create an Intents extension
2. When creating an intents extension, it also create an Intents UI extension where a view controller can be defined. This view controller will be shown by Siri as embedded view controller when Siri is processing the intent
3. Third step is to create a new Siri intents definition file. Which was not previously possible because Apple only allowed to have predefined domain of shortcuts This file will help to define model of the apps's custom intent.


The two parts of Siri's custom intent

1.Define the params that the user will provide to Siri
2. Define how the Siri should respond to the intent after handling the request

When we create a new intent model, it will generate a couple of files, for e.g. if the intent was for presence check of a person, the classes may be created are PresenceCheckIntent and PresenceCheckIntentProtocol


What next to be done is, in the App's extension class, implement the protocol and provide appropriate handling. The two main functions to override are

confirm
and handle


References:
https://willowtreeapps.com/ideas/wwdc-how-to-implement-siri-shortcuts-for-your-app

No comments:

Post a Comment