How to support Route Guidance in CarPlay Dashboard
April 9, 2020
CarPlay Dashboard consolidates music, maps, and Siri suggestions into a single screen inside your car for a safer, smarter experience. Starting with iOS 13.4, you can add support for CarPlay Dashboard in your navigation app, too: Make your map, upcoming maneuvers, and dashboard buttons available at a glance by adopting a few new capabilities inside the CarPlay framework.
Note: To integrate your app with CarPlay Dashboard, your CarPlay navigation app needs to support UIScene. For more information on adopting UIScene, check out “Introducing Multiple Windows on iPad”.
Get started with CarPlay Dashboard
To support CarPlay Dashboard inside your navigation app, you’ll need to update to Xcode 11.4 if you haven’t already.
iOS 13.4 offers new capabilities within the CarPlay framework: CPDashboardButton
, CPDashboardController
, and CPTemplateApplicationDashboardScene
.
CPTemplateApplicationDashboardScene is a new UIScene subclass that CarPlay creates when it determines that your app should appear in CarPlay Dashboard.
CPDashboardController and CPDashboardButton let you manage controls that appear in CarPlay Dashboard.
How to add support for CarPlay Dashboard
To take advantage of CarPlay Dashboard, start by supporting CPTemplateApplicationDashboardScene and its related protocol CPTemplateApplicationSceneDelegate.
Note: You need use CPTemplateApplicationSceneDelegate instead of CPApplicationDelegate to support this feature.
We’ll take you through each step below. In addition, we’ve provided a sample application scene manifest for your reference.
<key>UIApplicationSceneManifest</key>
<dict>
<key>CPSupportsDashboardNavigationScene</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<!-- For device scenes -->
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>UIWindowScene</string>
<key>UISceneConfigurationName</key>
<string>Phone</string>
<key>UISceneDelegateClassName</key>
<string>MyAppWindowSceneDelegate</string>
</dict>
</array>
<!-- For the main CarPlay scene -->
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneConfigurationName</key>
<string>CarPlay</string>
<key>UISceneDelegateClassName</key>
<string>MyAppCarPlaySceneDelegate</string>
</dict>
</array>
<!-- For the CarPlay Dashboard scene -->
<key>CPTemplateApplicationDashboardSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateDashboardScene</string>
<key>UISceneConfigurationName</key>
<string>CarPlay-Dashboard</string>
<key>UISceneDelegateClassName</key>
<string>MyAppCarPlayDashboardSceneDelegate</string>
</dict>
</array>
</dict>
</dict>
Step 1: Create a scene delegate
To begin, define a scene delegate for CPTemplateApplicationSceneSessionRoleApplication. This can be done dynamically in your UIApplicationDelegate by returning a configuration in application:configurationForConnectingSceneSession:options:, or ahead of time in your app's Info.plist in the Application Scene Manifest.
The delegate must conform to CPTemplateApplicationSceneDelegate, where it will be given an instance of CPInterfaceController and CPWindow, as you've been used to with CPApplicationDelegate.
Additionally, to support CPTemplateApplicationDashboardScene, include a new key in your Application Scene Manifest to declare support for CarPlay Dashboard: CPSupportsDashboardNavigationScene with a value of true.
Step 2: Define the dashboard delegate
Next define your delegate to the dashboard scene just like you would for the main template application scene. This delegate conforms to CPTemplateApplicationDashboardSceneDelegate and will be given an instance of CPDashboardController and UIWindow.
Step 3: Draw your CarPlay Dashboard content
Use the provided window to draw navigation related content for display in the CarPlay Dashboard, similar to the CPWindow given to the main template application scene. You can also provide two instances of CPDashboardButton to CPDashboardController that appear in the guidance card widget while your app is not actively navigating.
Step 4: Use your app in CarPlay Dashboard
People can interact with your app through both the dashboard buttons as well as within your main app interface. When navigation begins in your app using CPMapTemplate and CPNavigationSession, CarPlay will automatically display maneuvers in the guidance widget. When navigation ends, it will revert to your currently set dashboard buttons.
Resources
Learn more about creating apps for CarPlay
Learn more about integrating CarPlay with your navigation app in the Developer Library