Is iOS Carplay API Public? How to Integrate Carplay

Is iOS CarPlay API Public? How to Integrate CarPlay?

Update Oct, 2019:
A couple of years later, Apple opened up their designer guidelines and developer docs on CarPlay. As mentioned in some other comments as well, getting access to developer tools can be done on your mac as well.

Technically, depending on the type of app you want to be compatible with CarPlay, it requires different API's and frameworks. For example:

The CarPlay framework is for use by navigation apps only. If you want to add CarPlay support to your audio app, use MPPlayableContentManager. For messaging apps, use SiriKit’s Messaging-related intents to support reading and sending messages in CarPlay through Siri. For VoIP calling apps, use CallKit with SiriKit’s VoIP Calling-related intents to make and answer audio calls on a CarPlay system.

Legally, however, still the MFi Program requires application and approval by Apple for you to get the appropriate permissions, signing profile etc. in order to deploy it on an actual device. Let alone release it to market. OR... you can try applying for access manually and explain your case.

Lastly, there is also some documentation on how to enable tools and simulator to work with CarPlay. For example, a small excerpt:

CarPlay is supported by default when you run Simulator. However, you should configure the Simulator with extra options when developing a CarPlay navigation app. To enable extra options, enter the following command in Terminal before launching Simulator: defaults write com.apple.iphonesimulator CarPlayExtraOptions -bool YES.

But besides the documentation I can seriously recommend to read what the people at Flitsmeister blogged about on how to enable tooling on your local machine. Also, their road to finally getting approved was apparently tedious and far from smooth (I'm not affiliated with Flitsmeister), even though their use case is based on having lots of users (±1.5mln). Mentioning this to emphasise: CarPlay is apparently still not for the every day developer, just yet.


This question dates of early 2014. Let me update this with a mid 2016 answer:

TL;DR - No, it is not publicly available.

In order to get the tools, documentation, technical specs and even the license itself to develop for (amonst others) Carplay, you need to be enrolled with Apple's MFi Program.

Apple's MFi Program ("Made for iPhone/iPod/iPad") is a licensing program for developers of hardware and software. This is a specific license targeted at manufacturers, mostly of "mass production" units, that has additional benefits over the regular developer accounts for companies. These benefits include hardware components, tools, docs, techsupport and of course the license that you are allowed to develop specifically for these devices and technologies, like Carplay.

The MFi Enrollment FAQ is a decent read that makes everything pretty clear. But before you get your hopes up, do note that -again- it is only available for manufacturers. Like the FAQ states:

Q: Am I eligible to apply for the MFi Manufacturing License if my company does not own a manufacturing facility?

A: No. The MFi Manufacturing License is intended solely for companies that own one or more manufacturing facilities.

There are some exceptions. For example if you're a contractor, or an engineering design firm, that develops MFi accessories for a client (who is a manufacturer).

But basically put, it is not for the average developer and admission is quite strict. This means, in a nutshell, that Apple Carplay is not available to developer for by the, say, 95% of us.

How to update items of iOS Carplay templates

Use the CPTabBarTemplateDelegate method to update the contents of the template when it is selected :

func tabBarTemplate(_ tabBarTemplate: CPTabBarTemplate, didSelect selectedTemplate: CPTemplate) {
if let secondTemplate = selectedTemplate as? CPListTemplate {
secondTemplate.updateSections(...)
}
}

Create a list for CarPlay

Give this a try:

// In some function in the CarPlaySceneDelegate
Api().getStations { (stations) in

var stationItems: [CPListItem] = []

self.radios = stations

for station in stations {

let item = CPListItem(text: station.name,
detailText: station.description
image: station.image)

item.handler = { [weak self] item, completion in

// manage what should happen on tap
// like navigate to NowPlayingView

}

stationItems.append(item)
}

loadList(withStations: stationItems)
}

// Load the list template
private func loadList(withStations stations: [CPListItem]) {

let section = CPListSection(items: stations)
let listTemplate = CPListTemplate(title: "Select a station",
sections: [section])

// Set the root template of the CarPlay interface
// to the list template with a completion handler
interfaceController?.setRootTemplate(listTemplate,
animated: true) { success, error in

// add anything you want after setting the root template
}
}

The for loop to add the stations in a CPListItem array can be replaced by a map function but I did it this way for clarity.

Update

In your class CarPlaySceneDelegate, fix the spelling from

var interfactController: CPInterfaceController?

to

var interfaceController: CPInterfaceController?

In your templateApplicationScene didConnect comment out the interfactController?.setRootTemplate(listTemplate, animated: false) for now

and add this line to it self.interfaceController = interfaceController

So the updated function looks like this:

func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController) {

// Add this
self.interfaceController = interfaceController

Api().getStations { (stations) in

var stationItems: [CPListItem] = []

self.stations = stations

for station in stations {

let item = CPListItem(text: station.name,
detailText: station.name
// image: imageLiteralResourceName:"DRN1Logo")
)

item.handler = { [weak self] item, completion in

// manage what should happen on tap
// like navigate to NowPlayingView
print(item)
}

stationItems.append(item)
}

self.loadList(withStations: stationItems)
}
}

Do you see any better results ?

How to launch app in CarPlay Dashboard after click CPDashboardButton in CPDashboardController

Not sure this is the right way, but ther is no mention about this, not even the official sample app does it. But you can achieve it by calling open(_, options:, completionHandler) on dashboardScene.

Like this

dashboardController.shortcutButtons = [CPDashboardButton(titleVariants: ["Find"], subtitleVariants: ["place"], image: searchImage, handler: { _ in
guard let url = URL(string: "your.app.scheme://whatever/wherever") else { return }
templateApplicationDashboardScene.open(url, options: nil, completionHandler: nil)
})]

This will open the main app and calls open(_, urlContexts:) on main carplay scene where you can handle that url and react accordingly, like open search ar whatever.



Related Topics



Leave a reply



Submit