
CarPlay Audio and Navigation Apps
Learn how to update your audio or navigation app to support CarPlay. Apps in CarPlay are optimized for use in the car, and automatically adapt to available vehicle screens and input controls. Audio apps can deliver music, news, podcasts, and more. With the new CarPlay framework, Navigation apps can provide detailed maps, destination search, turn-by-turn guidance, and user notifications.
Resources
Related Videos
WWDC22
WWDC20
WWDC17
Welcome to CarPlay Audio andNavigation Apps.I'm Jonathan, an engineer on theiOS Car Experience Team.We are so excited to share someupdates with you today to helpyou build a great experience inCarPlay.
We'll start by reviewing CarPlayAudio apps.Then, we'll introduce the brandnew CarPlay framework for yournavigation apps.And we'll drive a quick detourto show you how easy it is tobuild a great navigationexperience in CarPlay.Let's start with a quick reviewof CarPlay.CarPlay is a smarter safer wayto use iPhone in the car.You can seamlessly performcommon scenarios while drivingusing your car's built-indisplay.You can make calls, send andreceive messages, listen toaudio, podcasts, and radio, andnow, get directions with yournavigation apps, all whilestaying focused on the road.
You can think of the car screenlike a second external displayfor your phone.Your app can present a versionof itself on the car screen withUI and features optimized foruse in the car.
There are some special designconsiderations for your app whenpresented in CarPlay.CarPlay vehicles have a widevariety of input styles.Some cars have touchscreens.Others have a rotary knob thatlets you move focus around andselect elements.And some have a touchpad thatallows for swipe gestures, andyou can even do character entryby tracing with your finger.
In a right-hand drive vehicle,the CarPlay status bar and appcontent will automaticallyswitch sides to be closest tothe driver.
Some cars, also, inform iOS whento transition to a darkinterface mode. Usually, when it's nighttime orwhen the vehicle's headlightsare turned on.
Your app can use this as asignal to, for example, updateyour map tile display style.CarPlay vehicles, also, supporta wide variety of screen sizesand aspect ratios.
iOS handles all of these inputmethods for you, so you canwrite your app just once forCarPlay and rest assured it'llbe supported on all of theseconfigurations.So, what kind of apps can youbuild in CarPlay?These are the five categories ofCarPlay apps.The car is a special place andif you have an app in one ofthese five categories you'llneed to apply for an entitlementfor your app to work in CarPlay.
If you're unsure whether yourapp fits into these categoriesand you're here at the conference, please come talk tous in our lab, later today.More details on that, soon.You can, also, go to this URL torequest an entitlement for yourapp. Let's quickly review thesecategories of CarPlay apps.
Auto maker apps are a specialcategory of CarPlay app.These apps are built by the automaker and work only in vehiclesfrom that manufacturer.They can display fullycustomized UIs for scenarioslike heating and cooling, seatcontrols, and other directintegrations with the vehicle.
SiriKit integration into theseapps allows you to change all ofthese settings with just yourvoice.
Last year, we introducedmessaging and VoIP apps toCarPlay.Your messaging and VoIP app cantap into SiriKit.So, your users can perform manycommon messaging tasks whileconnected to CarPlay, again,while staying focused on theroad.
Check out SiriKit for moredetails and see our session fromlast year, Enabling Your App forCarPlay.In a prior release of iOS, weintroduced third party audioapps to CarPlay.Audio apps use a templateinterface optimized for the car,where your app provides data andmetadata for the car's screen.We have some exciting newperformance improvements andoptimizations to share with youtoday for audio apps.And last but not least, todaywe're introducing the CarPlayframework, a brand new iOSframework for your navigationapps in CarPlay.
Just like with audio apps, iOSdisplays your app on the car'sscreen and handles the interfacewith the car.Your app doesn't need to worryabout input hardware or manyvehicle specific considerations.You only need to update your maptile experience to beappropriate for the car.The CarPlay framework provides afixed set of UI templates thatiOS renders on the car screen.
Your app decides how to createand configure these templatesand what actions to take inresponse to the user interactingwith your app's templates.We'll hear much more about theCarPlay framework, soon.Back to our CarPlay appcategories, today we'll befocusing on two of thesecategories; audio andnavigation.Let's start with audio apps.Albert.
Thanks, Jonathan.
I'm super stoked to talk to youall today about CarPlay audioapps.We're going to go through abrief overview of how to getyour audio app set up forCarPlay.Some performance improvementsand optimizations we've made foriOS 12, and some best practicesto make.And some common scenarios toaccount for when developing youraudio app for CarPlay.Now, driving and audio go handin hand. It's very clear that when you'redriving you want to listen toyour favorite hits, yourclassics, or even stream somepodcast episodes, or listen tothe latest news on radio.
We want to make sure that ifyou're developing an audio appthat you want to provide thebest experience to your drivers.
Now, to illustrate this, I wantto let you guys in on a littleside project that I've been working on.It's a little app that I thinkwill be a great hit.
My app is called Srirocka.
It combines two of my mostfavorite things; hot sauce andhot tracks.And with these synergies I thinkit'll be one of the top audioapps on the App Store when itlaunches.
Now, Srirocka is already a fullyfunctioning audio app and we'llneed to add CarPlay support toit. So, let me illustrate howthis'll be done.Like Jonathan mentioned, CarPlayuses templates that willabstract away many of thedifferent complexities CarPlayhas, such as input methods andscreen sizes, and so on.So, your audio app just needs tobe able to display informationonto the CarPlay display andprovide the best content.This is, usually, done by usinga table view or tabs, dependingon how you want to present yourdata.
You'll need to focus ondelivering the appropriatecontent to a CarPlay user.And if you're already developingan audio app, it uses existingAPIs you may be already familiarwith.So, let's take a look at this indetail. So, these are the three APIsthat you'll need to know tolaunch your app in CarPlay.
If you want to learn more aboutthis in detail, we had a sessionlast year that goes through thedetails of each single API.But I'll go through a briefsummary of every single one ofthese.
To browse your content on theCarPlay display, you'll need touse MPPlayableContent.MPPlayableContent has a datasource and a delegate, so thatyou or your audio app canpopulate your app's informationonto the CarPlay display.As well as a delegate to receivecallbacks whenever the userselects something on the CarPlaydisplay.
Now, if you already set NowPlaying metadata to ControlCenter or Lock Screen, or you'realready working on this on yourexisting audio app, you'realready familiar with these twoAPIs.
MPNowPlayingInfo Center allowsyou to populate your now playingmetadata and things such astitle and album artwork andetcetera onto the CarPlay's nowplaying screen.As well as Control Center andLock Screen if you've alreadybeen doing so.
MPRemoteCommandCenter allowsyour app to respond to remotecommand events, such as the Playcommand, Next Track, and so on.
We want to allow your CarPlayapp for a seamless Now Playingexperience.Now, let's take a look at howthis is done in code.So, when Srirocka is launched,I'm going to use Srirocka as anexample, here.This is what is needed at aminimum to support CarPlay audioapps.Srirocka will provide a datasource and a delegate toMPPlayableContentManager, sothat Srirocka can provideinformation to the CarPlaydisplay and respond whenabsolutely necessary.
Next, I've setNowPlayingInfoCenter to letMPNowPlayingInfoCenter know thatmy app will be providingNowPlaying metadata when itbecomes a Now Playing app.
And finally, I've responded toMPRemoteCommandCenter events.Specifically, just a Playcommand in this case, so thatwhen Srirocka becomes the NowPlaying app it can respond tothese events.
So, we can see here that the oneAPI that was needed for CarPlayis MPPlayableContent.And for iOS 12, we took a goodlook at how to better optimizethis and we can safely say, foriOS 12, we've remasteredMPPlayableContent.
We took a deep dive intoMPPlayableContent and we pushedfor performance improvements inhow the data source and delegatecalls are made.
Without changing your currentaudio app's implementation inCarPlay, we sped up the startupsequence and provided muchsmoother animations whenevercontent is changed on theCarPlay display.
We've also provided much bettercommunication to your app toanticipate whatever the user maywant to play or to browse on theCarPlay display.
Now, there's lots of room toimprove on your audio app.And let's see how we can dothis. The first of which, is that welooked into the implementationof reloadData.Which, is a call inMPPlayableContent, and figuredout how to better optimize thisfor your audio app.
What we found is that you shouldreally only call reloadData whenabsolutely needed.
What it does is that itdeconstructs the entire apps'hierarchy on the CarPlay displayand asks your audio app toreconstruct everything again.And this can be a very expensiveoperation, leaving your app notvery responsive.
Instead, if you just havecontent that just needs to beupdated, you should wrap themtogether inside of abeginUpdates and an endUpdatescall, so then that content canbe updated, appropriately.
Now, these calls thatMPPlayableContent has areasynchronous operations when weask you app for your data.So, keep an internalrepresentation or a cache ofyour information on somewhere inyour app.So, then that when we ask foryour content information you'reable to provide us informationquickly and makes your appresponsive.
Next, let's discuss some ways tofurther optimize your audioapp's performance in CarPlay.
So, Srirocka, already, has a bitof an implementation and ispartially implemented.And the user has decided to makea selection on the HeatingHabaneros playlist.It is one of the top playliststhat's super-hot.
But it seems to be stuckloading. We're not entirely sure what'sgoing on, here.And CarPlay, actually, willtimeout if the app doesn'tprovide content in time.Because it doesn't callcompletion handlers or justsimply isn't returning itsinformation.But what's going on, on thephone, here?So, CarPlay users are, usually,driving in areas where there'snot a speedy connection or theirscreen is locked.A vast majority of CarPlay usersare driving with the screenlocked and with a passcode.After all, they're driving.
If your app has data protectionpolicies that are dependent onthe phone being unlocked, youwon't be able to access yourapp's information and,ultimately, CarPlay willtimeout.So, if your data needs to beaccessed while the phone isunlocked, you'll need to audityour app's data intergradationpolicies.
The other issue is that you maybe driving in areas, or CarPlayusers are driving in areas withlittle to no cellularnetwork-tivity .
Drivers are driving everywhere,from the country roads and ruralareas, to big cities.And these are very varied areaswith different CarPlay,different data service.And you need to test forsituations that are not just theconstant WIFI networkconnection.
Now, Srirocka does account forall of this, as well.But it uses some very advancedmachine learning to see what arethe hottest tracks.And after all, all of thishappens on device, since privacyis a very important issue.And this just takes some time toprocess.Well, what happens in this case?We have an API calledbeginLoadingChildItems atindexPath to initiate fetchingcontent.
This API will be called wheneverany of your index paths arevisible on the CarPlay display.So, when the user is scrollingthrough table cells or selectingdifferent tabs,beginLoadingChildItems will becalled for every single indexpath that shows on the display.
This gives your app a chance tostart loading before the user,actually, selects the content.
And here's a code example insideof Srirocka, where when the usersees that the Heating Habanerosplaylist is visible on theCarPlay display, we startprocessing that playlist.And when the user makes aselection, will have either beenmidway through the networkrequest or ready to go and ableto provide content.
So, let's take a look at someapp scenarios that may occurwhen developing your app forCarPlay.
Now, Srirocka provides a veryrich user experience when loggedout.It's very clear here, withbeautiful typography and greatgraphic design, that the user islogged out and will need to login.
But how does this look onCarPlay?Well, Srirocka, actually,doesn't provide data when loggedout.And this leads to a very pooruser experience.The user doesn't really knowwhat's going on here and isn'table to interact with your app.
You should make sure that youshould provide some type ofexperience, so that the user canat least interact with your app,even if your app is logged out.So, this leads to a very gooduser experience for your audioapp. So, wrapping all this up, we cansay that CarPlay audio apps haveits greatest hits.
MPPlayableContent allows yourapp to provide templates to theCarPlay display so that your appcan provide users a good userexperience to the CarPlaydisplay.
You should account for realworld scenarios, such as whenyour app is logged out or yourscreen is locked, so then thatyour app can still functionbeautifully in CarPlay.
And with iOS 12, we made somegreat optimizations andperformance improvements to makeyour app even better in CarPlay.So, you should run your appagain and see if there's anyperformance improvements you canmake to your app, to make iteven better.
Now, to make us sure that we'resteering in the right direction,I'd like to invite my colleague,Mike, to talk about navigatingwith the CarPlay framework.Thank you.
All right. Thank you, Albert.
I am thrilled to share with you,today, how to add CarPlaysupport to your navigation apps.Navigation is such a huge partof the CarPlay experience andyour users will be so happy tosee their favorite apps on thecar screen.
As Jonathan and Albert havepreviously mentioned, we'veemployed a template basedapproach for previous appcategories. Your apps have been able toprovide data and metadata thatiOS will display on the carscreen and manage theseinteractions on your app'sbehalf.And this has worked extremelywell.But, we realize that navigationapps are a little bit different.Your apps have beautiful maps.And such incredible andimmersive navigationexperiences.And your users will expect tosee that on the car screen.
So, new in iOS 12, we'reintroducing the CarPlayframework.The CarPlay framework is yourtoolkit for building greatinteractive experiences on thecar screen.It uses a fixed set of templateobjects that your apps can buildand use, and that iOS willtranslate into a UI presented ontop of your app.
With this and a little bit ofeffort on your part, your appswill support all CarPlaysystems.
So, let's take a look at an appin CarPlay.
We've been building our ownnavigation app that we callCountry Roads.It takes us to our favoritedestinations using the scenicroute.And let's see what it looks likeon CarPlay.
We're looking at the CarPlayhome screen and you can see ourCountry Roads app icon rightthere with the rest of the appson iOS.
As we launch it, the first thingyou'll be greeted with is ourbeautiful map tiles.
When connected to CarPlay, anavigation app will be given awindow to draw content on thecar screen.This window is your canvas fordisplaying all that beautifulnoninteractive mapping andnavigation related content.
Then, as the app used templatesiOS will take those templatesand translate it into a UIpresented on top of your app.
So, let's take a look at thecode on what happens when yourapp is connected to CarPlay.
The first thing you'll need tonote is that your applicationdelegate will need to conform tothe CarPlay application delegateprotocol, CP ApplicationDelegate.
One function in that protocol isapplication didConnectCarInterfaceController to window.
This function will provide twovery important objects to yourapps.The first is an instance ofCPInterfaceController.
CPInterfaceController is yourconnection to the template worldand what your apps will use tomanage what is displaying on thecar screen.
Additionally, you're given thewindow I just mentioned, whichis where you can draw all yourmapping content.
You want to be sure to keep areference to both of theseobjects throughout the durationof the CarPlay session.
Next, you can create a new viewcontroller to populate thatwindow with content and assignit to windows review controller.And then, create a roottemplate.And using that interfacecontroller object, you cansetRootTemplate on the carscreen.
So, let's talk about some ofthese templates that areavailable in the CarPlayframework.And we'll start with one you'vealready seen and where yourusers will spend a majority oftheir time.And that is on the map template.
The map template is unique fromall the other templates in thatit is transparent to your appwindow.So, the content that you draw onthat window will be displayedunderneath the content providedby the map template.
The map template can beconfigured in a few differentplaces.You can place buttons in thenavigation bar.You can place up to four; two onthe leading side and two on thetrailing side.These are instances ofCPBarButton and are createdeither with text or images andare automatically sized andstyled by the system.
There's no notion of predefinedbutton actions in the CarPlayframework.But when you create a button,you provide a custom actionhandler. And when the user interacts withyour button on the car screenyour custom action handler willbe called in your app.You may also place up to fourbuttons that appear above yourmap window.And these are map buttons.You can create them with animage, and unlike the barbuttons, these are not styled bythe system.
The map template is also home toa lot of other mapping andnavigational relatedfunctionality.Such as panning the map,providing important contextualinformation to your users usingnavigation alerts.And of course, turn by turnguidance.
We're going to talk aboutguidance in a little bit.So, let's get started by goingover panning and navigationalerts.If your app supports panning themap, we require that you presenta button on the map template,either in the navigation bar oras a map button that enters panmode.
When a map template enters panmode it will display fourdirectional buttons that yourusers can interact with and aretranslated into an API, whereyour app only needs to knowwhich direction to pan the map.
This is an example of how theCarPlay framework has abstractedaway a lot of the complexitiesof all the various CarPlaysystems.These buttons can be interactedwith using touch, both highlatency and low latencytouchscreens.Using a rotary knob or touchpadto select one of these buttons.And additionally, for CarPlaysystems that have a rotary knobthat also supports joystick ofdirectional movement, those samemovements will be translatedinto this API.Your app does not need to worryabout where it came from.While your users are driving,you may want to presentinformation to them, such as aroad closure ahead or maybe, abetter route is available.For this, you can use navigationalerts.Navigation alerts present on themap template and can beconfigured with a title,subtitle, image, primary andsecondary action, and if itmakes sense, you can use adismiss interval after which thealert will self-dismiss.Let's take a look at some codeon how we built our roottemplate. And let's add a new button for amissing feature on our CountryRoads app.Since this was our function thatcreated out root template, thefirst thing we're going to do iscreate an instance ofCPMapTemplate.We will then create a new buttonfor a missing feature.
One of the great things aboutCountry Roads is that our userscan search for their favoritecategories.
And we'll add a new button forthat.So, let's create a CPBarButtonof type Image.And in its custom action handlerwe will call a function of ourown that is display our favoritecategories.
We'll then retrieve an image andassign it to the button.And we want this button toappear in the trailing spacealongside our traffic button.So, we'll assign those twobuttons to the trailingnavigation bar buttons on ourmap template.And then, return our maptemplate.
Great. Now, that we have abutton on our map template, wewant a way to display thosefavorite categories to ourusers.The CarPlay framework has agreat template for this.And that is the grid template.The grid template will displayan array of up to eight buttonsin a grid format.
These buttons appear here andcan be configured with an imageand a title.
The grid template also has anavigation bar, where you canplace the same leading andtrailing buttons.But you can also create a gridtemplate with a title that willappear in the navigation bar.
Let's jump over the code andlet's create a grid template.
We'll start by retrieving animage for our grid button.
We're going to add a Parksbutton. We'll then create an instance ofCPGridButton with a title ofParks and the image we justretrieved.
That, with the other buttons,we'll assign to an array.And then, create an instance ofCPGridTemplate with a title ofFavorites, since these are ourfavorite categories, and thearray of grid buttons we'vecreated in code.And this is where we jump backto that interface controllerobject I mentioned earlier.That is how we manage what ispresenting on the car screen.So, we would use that interfacecontroller to push this new gridtemplate onto the car screen.Now, that we have a way tosearch for our favoritecategories and our favoriteitems, we need a way to displaythe search results to our users.For that, we can use a listtemplate.
The list template will display alist of CPList items.They can be configured withtext, detailed text, an image,and a disclosure indicator.You can provide multiplesections. And you also, have a navigationbar where you can provide atitle and those same leading andtrailing buttons.One of the nice things about theCarPlay framework is that, whenappropriate, it will alsodisplay a nice scroll bar on theside that helps your users pagethrough their search resultswhile driving.
Let's build a list template.The first thing we're going toneed to do is take that array ofour own search results andtranslate them into an array ofCPListItems.So, we'll do that by using someof the properties on our searchresult class.
We will then initialize a newCPListTemplate with one sectionof those items, assign a titleof Parks, and also, assign adelegate to manage interactionfrom the user.
We, again, use the interfacecontroller to push our newtemplate onto the car screen.
When the user interacts with anitem on the screen listTemplatedidSelect item completionhandler will be called on yourlist template delegate.
There are a few other itemsavailable in the CarPlayframework that I'd like to goover, briefly.
The first is a great example ofhow complex CarPlay can be andhow the CarPlay framework helpsyou not have to worry aboutthat.What we're looking at, rightnow, is the search templateavailable in the CarPlayframework presenting atouchscreen keyboard.But one thing we've learned isthat not all CarPlay systemshave a touchscreen.Many only have a rotary knob ortouchpad for user interaction.
On those systems, whenappropriate, the CarPlayframework will display a linearstyle keyboard.
And of course, for thosetouchpads that do supportcharacter recognition, throughthe same search template APIyour app will receive thosecharacters as entered for free.
You may, also, want to presentinformation to your users in away that demands a little bitmore of their attention.For that, you can present aCPAlert in ActionSheetStyle orfor information that trulycommands their attention, youcan use a full screen template.
And lastly, since voice is sucha huge part of your apps, we'llbe providing a template thatwill help you manage voicecontrol. And with that, I'd like toinvite Jonathan back up to giveyou a demo of our Country Roadsapp. Jonathan.Thanks, Mike.Let's take a quick look atCountry Roads.
This is the CarPlay simulator.It's included with Xcode.
Let's start on the CarPlay homescreen, where we can see ourcustom navigation app enabledfor CarPlay.Let's tap the icon to launch ourapp.
When our app launches, we starton the map template.Here, the app overlay that Mikementioned is fully transparentand it allows our app'sbeautiful map tiles to showthrough.This map is really out of thisworld.I have some basic controls onthis map, like zooming in andout with ECP Map buttons.I can, also, switch in and outof pan mode using this panbutton.
All of these buttons are simpleconfigurable template objects.CarPlay tells my app when theuser has interacted with abutton and my app can zoom in orout or take any otherappropriate action in response.
That new Favorites button thatMike just added shows up in thenavigation bar on the trailingside.
When we tap it our app hascreated, configured, and pusheda grid template that lets usnavigate to certain veryimportant destinations.
If we select Parks our appcreates, configures, and pushesa list template where we canvisualize search results forinteresting nearby parks.We'll revisit Country Roads,shortly. But for now, back to Mike.
All right.Thanks, Jonathan.
So, let's talk about one of themost important functions thatyour apps will provide to yourusers while driving.And that, of course, isturn-by-turn guidance.
Let's start by walking through atypical flow your users may seewhile beginning a navigationsession.
The first thing they need is adestination.
This could be something that issurfaced by your app through anavigation alert.
Or perhaps, they've done asearch and found a destinationthey want to travel to.
They may want to, then, previewthe route and see importantinformation about it, such ashow long it might take to getthere and what their estimatedarrival time is.
If there are multiple routechoices for the trip they'reabout to take they'll probablywant to preview each of thoseroutes and make a choice thatsuits them best.
They'll then select a route andbegin navigation.This is when your app will beginproviding turn by turn updatesto the user.
Eventually, they'll arrive attheir destination or cancelnavigation.
And let's take a look at how youcan accomplish this same flowusing the CarPlay framework.Let's start by talking aboutRoute Preview.
Your app can provide data thatwill appear in a way that theuser can see and visualize allthe important details abouttheir upcoming trip.You can provide destinationnames, information that ispertinent to the route, such asadvisory notices.
You can, also, provide estimatesto let them know when they'llarrive.
And if the trip has multipleroutes the CarPlay frameworkwill automatically display amore routes button.
This will allow your users totoggle between individual routesand select the one that theywant to take.Let's look at the classes andmethods you'll want to befamiliar with to build anexperience in the CarPlayframework route preview.
The first is CPTrip.This is a representation of theupcoming trip for your users.It includes items such as theorigin and destination, as wellas multiple CPRouteChoices foreach route that they may take.
CPTravelEstimates describes howlong it will take for an entiretrip, as well as for individualmaneuvers.On your map template, when youare ready to show a routepreview to your users, you callShowTripPreviews on your maptemplate with the CPTrip objectyou've created.As the user toggles throughindividual routes you have anopportunity to update thecontent that is being displayedin your window.
MapTemplate selectedPreviewFortrip using routeChoice will becalled and you can change whatis being displayed.
This is a great opportunity tomention how the map template isdrawing content that covers upyour window.
And you'll want to make surethat the content you're drawingis visible to your users.
For this, we've leveraged theexisting safeArea API you mayalready be familiar with.
As the content changes from themap template it will update thesafeArea insets on your windowto let you know where it is safeto draw.You'll just want to implementsafeAreaInsetsDidChange and payclose attention to those insetsand make sure your content isdrawn within them.Now, let's talk about turn byturn guidance.
Similar to our preview, your appcan provide data to the CarPlayframework that will cause it todraw a guidance card populatedwith information, such as animage representing the maneuver.How much farther it is until youarrive there.
And of course, instructions onwhat to do when you get there,such as turn left or continuestraight.Let's take a look at what you'llneed to learn to use turn byturn guidance in the CarPlayframework. The CPMapTemplateDelegate andthe mapTemplate are two placesyou'll need to start.First, when the user hits thatgo button from Route PreviewmapTemplate startedTrip usingrouteChoice will be called onyour template delegate.This is your indication to beginnavigation to that destinationusing the route choice the userhas selected.This is when you would beginnavigation in your app, andalso, begin providing turn byturn updates to the CarPlayframework.You'll want to callstartNavigationSession for tripon your map template.And this will provide you withan instance ofCPNavigationSession.And this is where you managethose upcoming maneuvers.Using CPNavigationSession andCPManeuver you will set upcomingmaneuvers and the system willautomatically display a primarymaneuver. And if you provide a secondmaneuver it can display asecondary maneuver on thatguidance card.
You will then use updateestimates for maneuver tocontinually update what is beingshown in that guidance card.And let your users know whentheir maneuver is approaching.
And most likely, your app willbe playing back audio prompts tolet them know, as well.
For this, you'll want to makesure that your audio session isconfigured appropriately forCarPlay.
We have to remember that when inthe car your users may belistening to an audio sourcefrom iOS or they may belistening to an audio sourcefrom the car, such as FM radio.
You want to configure your audiosession withAVAudioSessionModeVoicePrompt asthis will let the CarPlay systemknow when to appropriately duckthe audio source, regardless ofwhere it's coming from.You can, also, configure yoursession with the categoryoptions duckOthers andinterruptSpokenAudioAndMixWithOthers.And this will help ensure thatyour audio plays well with otheriOS audio sources.
So, what happens next?Well, your users will continueto drive.
You'll want to continue to provide updated maneuvers andestimates and help them makethose turns when they need to.What happens if they veer offroute?Well, you might want tocalculate a new route.You can set a pause reason whichwill display a rerouting statusto the user.
Perhaps, a new route isavailable or something hasoccurred along the route.And you can use a navigationalert to present thatinformation to them, right thereon the map template.
And ultimately, they'll arriveat their destination, thanks toyour app.
So, we've talked a lot aboutwhat your apps can look likewhile frontmost on the carscreen. But we know that our users inCarPlay often switch betweentheir mapping app and an audioapp, like our favorite audio appSrirocka.
What happens when your app isbackgrounded and you need topresent important information toyour users?You will have an opportunity toprovide banner notificationsthat will display when the useris away from your app.
And this will work for maneuverupdates, as well as navigationalerts.
On your map template delegatethere are three methods you'llwant to implement.
The first is mapTemplate,ShouldShowNotificationFormaneuver.When you set a new maneuver andyour app is backgrounded thismethod will be called.And if you return true, thesystem will take that maneuverand translate it into a bannernotification.
If you're already presenting abanner notification for amaneuver, and simply areupdating the travel estimates,mapTemplate shouldUpdateNotificationFormaneuver with travelEstimateswill be called. Allowing you to update thecontent that appears in thatbanner. So, instead of rolling a newnotification, you can simplyupdate the contents that arealready there.
And for navigation alerts, youwill have an opportunity todisplay those, as well, usingmapTemplateshouldShowNotificationFornavigationAlert.
With that, I'd like to inviteJonathan up one more time togive you a demo of how we'veintegrated our Country Roads appwith the CarPlay framework to doroute preview and turn-by-turnguidance.Jonathan.Thanks, Mike.
Let's take a quick look at somecode for how your navigationapps can provide guidance inCarPlay using our sample CountryRoads app.
When the user selects adestination, we're going to grabthat placemark and hand thecurrent location and destinationto our navigation engine tocalculate some route choices.For our purposes here, we haveonly a single route choice, butyour navigation engine canprovide multiple alternativerouting options when available.Plus, we can include some extradetails to help the user make aninformed decision about a route.We'll create a CPTrip and callshowTripPreviews to informCarPlay that we're startingnavigation guidance.Lastly, we'll update theestimates to provide our user anETA for this trip.Let's take a quick look at howwe can provide the maneuversthat CarPlay needs fornavigation.When our user has selected aroute and started navigation,first we can hide the routepreviews that our user wasbrowsing.We'll tell our map template tostart a navigation session.And we can move the session tothe loading state while we'recalculating maneuvers.We'll build a list of CPmaneuver objects from ournavigation engine.And last but not least, we'llprovide the first instruction toour navigation session.And now, we're ready to drive.Let's see it in action.
All right.Let's browse to our Favoriteslist and choose Parks.When we tap one of theselocations we'll see our app popsback to the map template andpresents a route guidance card.
If we choose to start guidanceby tapping on the Go buttonhere, we'll see the app enternavigation mode.
Your app can also update the Navbar if needed to show custombuttons for navigation mode,like a Cancel button or a togglefor voice prompts.Looks like we're making prettygood time, here.
When we arrive at ourdestination our app transitionsback out of navigation mode.
That's it for maps with theCarPlay framework.Let's review the roads thatwe've driven together today.
We've shown you some big CarPlayaudio performance improvementsand optimizations for a betterexperience for your users.We introduced the brand newCarPlay framework for navigationand guidance apps in CarPlay.Your app can work seamlessly ondifferent strings and inputdevices.You're the navigation expertsand you only have to do what youdo best; draw beautiful maps inyour beautiful apps.And we'll take care of the rest.
You can draw your map template,use CPMapTemplate andCPNavigationSession to managenavigation.And show other templates asneeded to present informationand handle user interactions.
If you have any questions forus, please come meet our team atthe CarPlay lab, later today, inLab 11 at 2 p.m.You can, also, check outdeveloper.apple.com/carplay formore details.Otherwise, you have everythingyou need to build a greatCarPlay app.And we are so excited to seewhat you create.Thank you so much.[ Applause ]
[8]ページ先頭