development
MKDirectionsRequest
An iOS API object that contains routing request data (source, destination, transport type, time preferences) sent from Apple Maps to a routing app.
MKDirectionsRequest is a class in Apple’s MapKit framework that packages all the information a user provides when asking for directions in Apple Maps. When a user selects your routing app as the directions provider, iOS creates an MKDirectionsRequest object and delivers it to your app through its launch URL or app delegate.
What the Request Contains
The object includes the source and destination as map items, the requested transport type (automobile, walking, transit, or any), and optional departure or arrival times. Your app reads these properties to understand exactly what the user needs. For transit apps, the departure and arrival date fields are especially important because users often plan trips around specific schedule windows. The transport type tells your app which routing mode the user selected so it can return the correct kind of directions.
Handling the Request in Your App
Your app receives the MKDirectionsRequest when iOS launches it through a URL scheme or universal link. You extract the source and destination coordinates, determine the best route using your own data and algorithms, then present the results in your interface. If the request falls outside your coverage area or your app cannot fulfill it for another reason, you should display a clear message rather than failing silently. A smooth handoff from Apple Maps into your app builds user trust and encourages repeat usage.