113
#WWDC17 © 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Albert Wan, CarPlay Engineering Enabling Your App for CarPlay Session 719 App Frameworks

Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

#WWDC17

© 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Albert Wan, CarPlay Engineering

•Enabling Your App for CarPlay • Session 719

App Frameworks

Page 2: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Agenda

•How apps run in CarPlay •CarPlay app integration

Page 3: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

•How Apps Run in CarPlay

Page 4: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Features Available to All Apps in CarPlay

Now Playing information and playback controls

Audio plays through car’s speakers

SiriKit (for appropriate intents)

Page 5: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices for All Apps

Don’t play audio automatically unless requested

Configure the audio session

Page 6: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices for All Apps

Don’t play audio automatically unless requested

Configure the audio session

Spoken audio apps • AVAudioSessionModeSpokenAudio

Page 7: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices for All Apps

Don’t play audio automatically unless requested

Configure the audio session

Spoken audio apps • AVAudioSessionModeSpokenAudio

Navigation apps • AVAudioSessionModeSpokenAudio • AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers

• Set mixable before making audio active

Page 8: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

CarPlay Enabled Apps

Appear on the CarPlay home screen

Run in the foreground on both screens

Page 9: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

CarPlay Enabled Apps

Supported app categories • Audio apps • Messaging and VoIP calling apps • Automaker apps

Request CarPlay entitlementhttp://developer.apple.com/carplay

Entitlement setup and provisioning

Page 10: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Designing for CarPlay

For icon guidance, see “App Icon” in “iOS Human Interface Guidelines”

For design guidelines, see “CarPlay Human Interface Guidelines”

Page 11: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Audio limitations (playback state)

Test on device and with an actual head unit

Wireless debugging in Xcode

Xcode and Simulator

Debugging with Xcode 9 Hall 2 Wednesday 10:00AM

Page 12: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Data Protection

Apps can run in CarPlay while the iPhone is passcode locked

Passcode protected data may be unavailable

Page 13: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

FilesFileProtectionType.complete FileProtectionType.completeUnlessOpen

Data Protection

Apps can run in CarPlay while the iPhone is passcode locked

Passcode protected data may be unavailable

Page 14: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

FilesFileProtectionType.complete FileProtectionType.completeUnlessOpen

KeychainkSecAttrAccessibleWhenPasscodeSetThisDeviceOnly kSecAttrAccessibleWhenUnlocked kSecAttrAccessibleWhenUnlockedThisDeviceOnly

Data Protection

Apps can run in CarPlay while the iPhone is passcode locked

Passcode protected data may be unavailable

Page 15: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

FilesFileProtectionType.complete FileProtectionType.completeUnlessOpen

KeychainkSecAttrAccessibleWhenPasscodeSetThisDeviceOnly kSecAttrAccessibleWhenUnlocked kSecAttrAccessibleWhenUnlockedThisDeviceOnly

SQLite SQLITE_OPEN_FILEPROTECTION_COMPLETE SQLITE_OPEN_FILEPROTECTION_COMPLETEUNLESSOPEN

Data Protection

Apps can run in CarPlay while the iPhone is passcode locked

Passcode protected data may be unavailable

Page 16: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

•CarPlay App Integration

Page 17: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

CarPlay App Integration

•Audio Apps •Messaging and VoIP Calling Apps •Automaker Apps

Page 18: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

•Audio Apps

Page 19: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Audio Apps

Page 20: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Audio Apps

800 x 480 hero shot of audio app Now Playing view Probably Podcasts app

Page 21: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Audio Apps

Implement the MPPlayableContent API • MPPlayableContentDataSource, MPPlayableContentDelegate

Respond to MPRemoteCommandCenter events

Update MPNowPlayingInfoCenter

Page 22: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Running

Afternoon Jams

The Chainsmokers

Macklemore

Taylor Swift

Little Voice

Building the Data Source

Playlists

Eye of the Tiger

Artists

Albums

Shake It Off

Fifteen

Page 23: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

(1, 2)

(2, 0)

(0, 0, 0)

(1, 2, 0)

(1, 2, 1)

(1, 1)

(1, 0)

(0, 1)

(2)

(1)

(0)

contentItem at (0, 0)

Afternoon Jams

The Chainsmokers

Macklemore

Taylor Swift

Little Voice

Playlists

Eye of the Tiger

Artists

Albums

Shake It Off

Fifteen

Running(0, 0)

Page 24: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

(1, 2)

(2, 0)

(0, 0, 0)

(1, 2, 0)

(1, 2, 1)

(1, 1)

(1, 0)

(0, 1)

(2)

(1)

(0)

contentItem at (0, 0)

Afternoon Jams

The Chainsmokers

Macklemore

Taylor Swift

Little Voice

Playlists

Eye of the Tiger

Artists

Albums

Shake It Off

Fifteen

Running(0, 0)

Page 25: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

(2, 0)

(0, 0, 0)

(1, 2, 0)

(1, 2, 1)

(1, 1)

(1, 0)

(0, 1)

(2)

(1)

(0) (0, 0)

numberOfChildItems at (1,2)

Afternoon Jams

The Chainsmokers

Macklemore

Little Voice

Playlists

Eye of the Tiger

Artists

Albums

Running

Taylor Swift

Shake It Off

Fifteen

(1, 2)

Page 26: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

(2, 0)

(0, 0, 0)

(1, 2, 0)

(1, 2, 1)

(1, 1)

(1, 0)

(0, 1)

(2)

(1)

(0) (0, 0)

numberOfChildItems at (1,2)

Afternoon Jams

The Chainsmokers

Macklemore

Little Voice

Playlists

Eye of the Tiger

Artists

Albums

Running

Taylor Swift

Shake It Off

Fifteen

2 Children(1, 2)

Page 27: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Content Limits

Content limits may be enforced that can truncate the number of rows and container depth

Take changes into account with MPPlayableContentManager

Page 28: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

extension YourAppContentManager : MPPlayableContentDelegate { // called whenever CarPlay state changes func playableContentManager(

_ contentManager: MPPlayableContentManager, didUpdate context: MPPlayableManagerContext) {

// check to see if content limits are enforced let contentLimitsEnforced = context.contentLimitsEnforced if contentLimitsEnforced { // the maximum number of items shown in a list when content limits are enforced let contentLimitItemCount = context.enforcedContentItemsCount // the maximum depth in the hierarchy when content limits are enforced let contentLimitTreeDepth = context.enforcedContentTreeDepth } else { … } } }

Page 29: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Tabs

Tabs—Add UIBrowsableContentSupportsSectionedBrowsing to Info.plist

Recommended to have at most 4 tabs for space constraints

Keep tab titles as short as possible for narrow screens and Now Playing button

Tab image assets will be rendered as template images

Page 30: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Now Playing Screen

Page 31: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

// Set Metadata to be Displayed in Now Playing Info Center

let infoCenter = MPNowPlayingInfoCenter.default() infoCenter.nowPlayingInfo = [MPMediaItemPropertyTitle: "Style", MPMediaItemPropertyArtist: "Taylor Swift", MPMediaItemPropertyAlbumTitle: "1989", MPMediaItemPropertyGenre: "Pop", MPMediaItemPropertyReleaseDate: "2014", MPMediaItemPropertyPlaybackDuration: 231, MPMediaItemPropertyArtwork: mediaItemArtwork, MPNowPlayingInfoPropertyElapsedPlayback: 53, MPNowPlayingInfoPropertyDefaultPlaybackRate: 1, MPNowPlayingInfoPropertyPlaybackRate: 1, MPNowPlayingInfoPropertyPlaybackQueueCount: 13, MPNowPlayingInfoPropertyPlaybackQueueIndex: 3, … ]

Page 32: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Playback Controls

MPRemoteCommandCenter • Play, pause, stop • Previous track, next track • Seek backward, seek forward • Skip backward, skip forward • Shuffle, repeat • Like, dislike, bookmark • Change playback rate

Page 33: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Changing Playback Rate

Add default playback rate to MPNowPlayingInfoCenter:

MPNowPlayingInfoPropertyDefaultPlaybackRate

Implement changePlaybackRateCommand with supportedPlaybackRates in MPRemoteCommandCenter

NEW

Page 34: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

// Change Playback Rate

let infoCenter = MPNowPlayingInfoCenter.default() infoCenter.nowPlayingInfo = [MPNowPlayingInfoPropertyDefaultPlaybackRate: 1.0, … ]

let changePlaybackRateCommand = MPRemoteCommandCenter.shared().changePlaybackRateCommand changePlaybackRateCommand.supportedPlaybackRates = [0.5, 1.0, 1.5, 2.0]

Page 35: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Playback Controls

If multiple commands are specified, CarPlay may combine them into a single button

Page 36: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Playback Controls

If multiple commands are specified, CarPlay may combine them into a single button

Page 37: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Call the completion handler when content is ready to play or be displayed

Return at least one row in the root table view for non-tabbed apps

If your app has initial setup, populate the first row with an MPContentItem that is neither playable nor a container indicating the state of the app to the user

Page 38: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Chris Whitney, CarPlay Engineering

•Messaging and VoIP Calling Apps

Page 39: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Messaging and VoIP Calling Apps

Page 40: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Messaging and VoIP Calling Apps

Page 41: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Messaging and VoIP Calling Apps

Messaging • SiriKit Messaging Intents • CarPlay Messaging Entitlement

Page 42: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Messaging and VoIP Calling Apps

Messaging • SiriKit Messaging Intents • CarPlay Messaging Entitlement

VoIP Calling • SiriKit Calling Intents • CarPlay VoIP Calling Entitlement • CallKit

Page 43: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Required SiriKit Intents for Messaging Apps

Page 44: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Required SiriKit Intents for Messaging Apps

Send a message • INSendMessageIntent

Page 45: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Required SiriKit Intents for Messaging Apps

Send a message • INSendMessageIntent

Search for messages • INSearchForMessagesIntent

Page 46: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Required SiriKit Intents for Messaging Apps

Send a message • INSendMessageIntent

Search for messages • INSearchForMessagesIntent

Set attributes on a message • INSetMessageAttributeIntent

Page 47: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Required SiriKit Intents for VoIP Calling Apps

Page 48: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Start an audio call • INStartAudioCallIntent

Required SiriKit Intents for VoIP Calling Apps

Page 49: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Start an audio call • INStartAudioCallIntent

Search call history • INSearchCallHistoryIntent

Required SiriKit Intents for VoIP Calling Apps

Page 50: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Start an audio call • INStartAudioCallIntent

Search call history • INSearchCallHistoryIntent

Required SiriKit Intents for VoIP Calling Apps

What’s New in SiriKit Grand Ballroom B Wednesday 1:50PM

Making Great SiriKit Experiences Grand Ballroom A Thursday 11:00AM

Page 51: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

CallKit

Page 52: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Report incoming calls

CallKit

Page 53: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Report incoming calls

Handle call actions • Start, answer, end • Mute, grouping, holding, keypad tones

CallKit

Page 54: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Report incoming calls

Handle call actions • Start, answer, end • Mute, grouping, holding, keypad tones

CallKit

Enhancing VoIP Apps with CallKit WWDC 2016

Page 55: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Notifications

Page 56: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Notifications

Request authorization for CarPlay

Page 57: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Notifications

Request authorization for CarPlay

Separate message notifications into an exclusive notification category

Page 58: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Notifications

Request authorization for CarPlay

Separate message notifications into an exclusive notification category

Add the CarPlay category option

Page 59: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Notifications

Request authorization for CarPlay

Separate message notifications into an exclusive notification category

Add the CarPlay category option

Set a SiriKit intent to handle notification selection

Page 60: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

let authorizationOptions : UNAuthorizationOptions = [.badge, .sound, .alert, .carPlay]

let notificationCenter = UNUserNotificationCenter.current()

notificationCenter.requestAuthorization(options: authorizationOptions) { (granted, error) in

// Enable or disable app features based on authorization

}

let messageCategory = UNNotificationCategory(

identifier: "messages",

actions: […],

intentIdentifiers: [INSearchForMessagesIntentIdentifier],

options: .allowInCarPlay)

notificationCenter.setNotificationCategories([messageCategory])

Page 61: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Page 62: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Don’t show message contents in a notification’s title or subtitle

Page 63: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Don’t show message contents in a notification’s title or subtitle

Mark content as read in SiriKit

Page 64: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Don’t show message contents in a notification’s title or subtitle

Mark content as read in SiriKit

Show notifications for missed calls and message delivery failures

Page 65: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

•Automaker Apps

Page 66: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Automaker Apps

Page 67: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Automaker Apps

Page 68: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Automaker Apps

Created by the car’s manufacturer to provide information and control features

Page 69: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Automaker Apps

Created by the car’s manufacturer to provide information and control features

Automaker-specific entitlement

Page 70: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Automaker Apps

Created by the car’s manufacturer to provide information and control features

Automaker-specific entitlement

Display a user interface in CarPlay

Page 71: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Requirements for Automaker Apps

Created by the car’s manufacturer to provide information and control features

Automaker-specific entitlement

Display a user interface in CarPlay

Only appear on supported vehicles from the automaker

Page 72: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

Page 73: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.performance com.sampleautos.climate

Page 74: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

com.sampleautos.performance com.sampleautos.climate

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

Page 75: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

com.sampleautos.performance

com.sampleautos.performance com.sampleautos.climate

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

Page 76: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

com.sampleautos.performance

com.sampleautos.performance com.sampleautos.climate

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

Page 77: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Track Laps

com.sampleautos.performance com.sampleautos.climate

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

Page 78: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.performance com.sampleautos.climate

Page 79: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.radio com.sampleautos.climate

com.sampleautos.performance com.sampleautos.climate

Page 80: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.radio com.sampleautos.climate

com.sampleautos.performance com.sampleautos.climate

Page 81: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

Comfort

com.sampleautos.performance com.sampleautos.climate

Page 82: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.performance com.sampleautos.climate

Page 83: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.electric

com.sampleautos.performance com.sampleautos.climate

Page 84: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Matching Automaker Apps to Vehicles CarPlay Protocols Entitlement

com.sampleautos.electric

com.sampleautos.performance com.sampleautos.climate

Page 85: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Communicating with the Vehicle

Page 86: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Communicating with the Vehicle

Use External Accessory Framework

Page 87: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Communicating with the Vehicle

Use External Accessory Framework • Define a custom protocol

Page 88: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Communicating with the Vehicle

Use External Accessory Framework • Define a custom protocol• Implement the protocol in the vehicle’s software

Page 89: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Communicating with the Vehicle

Use External Accessory Framework • Define a custom protocol• Implement the protocol in the vehicle’s software• Observe accessory connection events

Page 90: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Communicating with the Vehicle

Use External Accessory Framework • Define a custom protocol• Implement the protocol in the vehicle’s software• Observe accessory connection events• Initialize an EASession for the protocol

Page 91: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Adding a CarPlay User Interface

Page 92: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Adding a CarPlay User Interface

Observe UIScreen connection events

Page 93: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Adding a CarPlay User Interface

Observe UIScreen connection events

Verify the screen’s traits contain UIUserInterfaceIdiomCarPlay

Page 94: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Adding a CarPlay User Interface

Observe UIScreen connection events

Verify the screen’s traits contain UIUserInterfaceIdiomCarPlay

Create a UIWindow with a root view controller

Page 95: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

var carWindow: UIWindow?

func updateCarWindow() { guard let screen = UIScreen.screens.first(where: { $0.traitCollection.userInterfaceIdiom == .carPlay }) else { // CarPlay is not connected self.carWindow = nil; return } // CarPlay is connected let carWindow = UIWindow(frame: screen.bounds) carWindow.screen = screen carWindow.makeKeyAndVisible() carWindow.rootViewController = CarViewController(nibName: nil, bundle: nil) self.carWindow = carWindow }

Page 96: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

updateCarWindow()

let notificationCenter = NotificationCenter.default notificationCenter.addObserver(self, selector: #selector(screenDidUpdate(notification:)), name: .UIScreenDidConnect, object: nil) notificationCenter.addObserver(self, selector: #selector(screenDidUpdate(notification:)), name: .UIScreenDidDisconnect, object: nil) @objc func screenDidUpdate(notification: Notification) { updateCarWindow()}

Page 97: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

UIKit in CarPlay

Page 98: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

UIKit in CarPlay

UIButtonTypeSystem displays with a CarPlay style

Page 99: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

UIKit in CarPlay

UIButtonTypeSystem displays with a CarPlay style

UITableViewController may limit table length

Page 100: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

UIKit in CarPlay

UIButtonTypeSystem displays with a CarPlay style

UITableViewController may limit table length

UIFocusEnvironment responds to input device events

Page 101: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

UIKit in CarPlay

UIButtonTypeSystem displays with a CarPlay style

UITableViewController may limit table length

UIFocusEnvironment responds to input device events

Limited availability of system user interface elements

Page 102: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

SiriKit for Automaker Apps

Page 103: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

SiriKit for Automaker Apps

Car Commands Intents • Lock and unlock • Fuel or charge level • Signal tone and lights

Page 104: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

SiriKit for Automaker Apps

Car Commands Intents • Lock and unlock • Fuel or charge level • Signal tone and lights

CarPlay Intents • Climate, defroster, and seat heater settings • Radio and audio source selection

Page 105: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Page 106: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Make your app useful even when outside of the car

Page 107: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Make your app useful even when outside of the car

Consider forwards and backwards compatibility

Page 108: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Make your app useful even when outside of the car

Consider forwards and backwards compatibility

Simplify the user interface – buttons, labels, tables, navigation, tabs

Page 109: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Best Practices

Make your app useful even when outside of the car

Consider forwards and backwards compatibility

Simplify the user interface – buttons, labels, tables, navigation, tabs

Determine how focus should move between UI elements

Page 110: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

More Informationhttps://developer.apple.com/wwdc17/719

Page 111: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Related Sessions

Debugging with Xcode 9 Hall 2 Wednesday 10:00AM

What’s New in SiriKit Grand Ballroom B Wednesday 1:50PM

Making Great SiriKit Experiences Grand Ballroom A Thursday 11:00AM

Developing Wireless CarPlay Systems WWDC 2017 Video

Enhancing VoIP Apps with CallKit WWDC 2016

Developing CarPlay Systems, Part 1 WWDC 2016

Developing CarPlay Systems, Part 2 WWDC 2016

Page 112: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit

Labs

CarPlay Lab Technology Lab D Wednesday 4:10PM–6:00PM

SiriKit Lab Technology Lab B Wednesday 3:10PM–5:00PM

SiriKit Lab Technology Lab C Friday 9:00AM–12:00PM

Page 113: Albert Wan, CarPlay Engineering - Apple Inc. · Features Available to All Apps in CarPlay Now Playing information and playback controls Audio plays through car’s speakers SiriKit