CarPlay support in the Navigation SDK
This page uses v1.4.2 of the Mapbox Navigation SDK. A newer version of the SDK is available. Learn about the latest version, v2.19.0, in the Navigation SDK documentation.
CarPlay is supported by default in the Mapbox Navigation SDK for iOS. This means that any app using the Navigation SDK can connect directly to CarPlay-enabled car infotainment screens.
Get started with CarPlay
The Mapbox Navigation SDK for iOS provides useful building blocks of functionality built on top of the CarPlay framework. Before you start using the Navigation SDK for iOS with CarPlay, you need to:
- Get an entitlement from Apple. Before you can develop and run an app on the iOS simulator or device, including the Mapbox example app that’s included in the Navigation SDK for iOS, your Apple Developer Program team agent needs to get a CarPlay entitlement from Apple.
- Read the CarPlay Navigation App Programming Guide. It’s important for you to understand the CarPlay framework and design for its strengths and limitations. This will help you create an optimal product experience for your users as you build with the Navigation SDK. Apple’s CarPlay Navigation App Programming Guide contains a lot of useful information, and we highly recommend reading it before you begin your development process.
Design your app
Mapbox provides building blocks for creating CarPlay-enabled iOS applications using Mapbox maps and navigation. But it’s still up to you to design and build the product that you want to deliver! Consider the user’s journey with your app while they are connected, as well as when they are connecting or disconnecting with the CarPlay unit, and design your application with the user’s safety in mind.
While the Mapbox Navigation SDK for iOS includes default map styles with traffic and incidents, you can also design your own custom map styles using Mapbox Studio and display them to your users on CarPlay.
User activities to consider
Mapbox provides building blocks and a CarPlay example app to help speed up your development for each user activity. Ultimately, though, it’s up to you to design and build the experience you want to deliver and to make sure there are no user interface "dead ends" in your application.
The user experience on CarPlay's top bar navigation and map view functionality is logically divided into three distinct user activities: browsing, previewing, and navigating. Learn more about how to develop for these user activities using the Navigation SDK in the Mapbox Navigation SDK for iOS CarPlay Reference.
Browsing
In the browsing state, the user can browse the application menus. For example, they could search for a destination or browse a list of favorites, history, or recommended nearby locations.
The map view will also follow the user as they drive. The user can zoom and pan the map, and recenter it on themselves if they choose to do so.
While Mapbox provides some example CarPlay template buttons and views, we strongly recommend that you design your own experience and implement your own template buttons and provide them to the Mapbox CarPlay integration via your CarPlayManagerDelegate
implementation when requested by the CarPlayManager
.
Previewing
When the user searches for a route, one or more results will be returned. To start active guidance, the user will need to select which route to follow and confirm. If more than one route is returned, the user will be able to switch between them to preview the routes before continuing.
It is possible to provide different top bar buttons for the user when they are selecting and confirming a route, and we recommend doing so. For example, you could give users the opportunity to cancel, or to save a route for later, depending on your user experience design. When the app enters this state, the CarPlayManager
will ask its delegate for updated buttons appropriate for this user activity.
Navigating
After the navigation process begins in your app, the user receives turn-by-turn directions to navigate their chosen route. If they stray from the route, a new route is generated. After the journey is complete, you can also present the user with a feedback screen to collect user input.
Again, we strongly recommend that you provide your users with different activity-specific functionality using different top bar buttons. For example, you could give users the option to cancel a route, enable or disable voice instructions, and other activity-specific functions. The CarPlayManager
will ask its delegate for updated buttons appropriate for this activity. Design carefully for this activity, and allow your users to safely arrive at their destination while avoiding the unnecessary distraction of a sub-optimal user experience. Make sure there are no dead-ends in your app’s user experience when navigating the top bar menus.
Begin your integration
Apple has designed the CarPlay framework with a protocol based on the UIApplicationDelegate
protocol, CPApplicationDelegate
. Mapbox provides an example implementation of key CPApplicationDelegate
methods that configures the shared CarPlayManager
object. This example implementation should be placed in your application delegate, possibly as an extension or as another delegate class. The Mapbox Example-CarPlay application included in the Navigation SDK for iOS codebase includes an example of this integration.
Besides configuring the CarPlayManager
object in your CPApplicationDelegate
implementation, you can also use the CPApplicationDelegate
methods to trigger your own application events, such as a user interface change on the phone or logging an application-specific event.
CarPlayManagerDelegate
offers additional opportunities for customization beyond connection and disconnection. Using this protocol, the Mapbox Navigation SDK for iOS will notify your application of key transitions in application state between the three activities described above, request updated leading, trailing, and map template buttons, and other important events.
Test your integration
As with all iOS applications, it is important to test your app on a real device in the real world. Testing is even more important with CarPlay since available head units have a wide variety of different capabilities, screen resolutions, and input devices. You should plan to devote considerable design and development time to testing with real hardware to understand how your application experience changes when it is connected to a vehicle.
Further resources
- Mapbox Navigation SDK CarPlay API reference
- CarPlay developer documentation
- CarPlay audio and navigation apps introduction