The handler interface for booking a ride for the user.
- iOS 10.0+
- watchOS 3.2+
Use the methods of the
INRequest protocol to resolve, confirm, and handle requests to book a ride using your service. Adopt this protocol in an object of your Intents extension that is capable of initiating the booking process with your service. SiriKit calls the methods of your object to resolve the parameters to your ride-related information and to book the ride upon confirmation by the user.
Ride requests have many items to resolve. It is recommended that you resolve all options in some manner, but you may omit options that are not relevant to your service. For example, if your service transports cargo instead of passengers, you might ignore the party size option. For ride requests, you must resolve the following items:
Handling a Ride Request
Handling a ride request involves booking the ride with your service and providing SiriKit with the status of the booking. The details of how you book rides through your service are up to you. You need to schedule the ride, find a vehicle and a driver, and arrange payment from the user. The
INRequest object contains information about what the user needs. Pass the information in that object to your service and use the results to configure the response object you return to SiriKit.
Listing 1 shows an example of how you might book a ride and provide a response. Because booking the actual ride is a custom process, the example calls several custom methods to implement key phases of that process. The first of these methods uses information from the intent object to register the request with a fictional service and retrieve an ID string identifying the request. That ID string is used to retrieve specific information from the service regarding the vehicle type, driver, and ride option. All of the retrieved information is used to build the
INRide object that is added to the
INRequest object passed back to SiriKit.
When creating responses, providing an
NSUser object is optional and necessary only when you want to include custom information for your app. If you specify
nil, SiriKit creates a user activity object for you as needed. For more information on configuring the response object, see