Provide SiriKit with an object capable of handling a given intent.
When a user makes a request of your app using Siri or Maps, SiriKit loads your Intents app extension and creates an instance of its
INExtension subclass. The job of your extension object is to provide SiriKit with the handler objects that you use to handle specific intents. You provide these objects from the
handler method of your extension object.
The structure of the
handler method is the same for all Intents app extensions, and that method must return a valid new object for all intents that your Intents app extension supports. Listing 1 shows a version of the method that supports intents in the messages and VoIP calling domains. After checking the type of the provided intent object, the method creates and returns an object capable of handling that intent.
The object you return from the
handler method must implement the specific protocol needed to handle the corresponding intent. Each intent object has an associated protocol whose name is based on the name of the intent. For example, when handling an
INStart object, you provide an object that adopts the
INStart protocol. The protocol defines the methods that your object must implement to resolve any intent parameters and to let SiriKit know how you handled the intent.
SiriKit typically creates multiple copies of your handler object when processing a single intent object and calls only one method on each object. Do not store cached state information in a handler object because that information will not be present during subsequent method calls. Instead, always make fresh requests for any needed data from each of your methods.