CarPlayManager
@available(iOS 12.0, *)
public class CarPlayManager : NSObject
extension CarPlayManager: CPApplicationDelegate
extension CarPlayManager: CPInterfaceControllerDelegate
extension CarPlayManager: CPMapTemplateDelegate
extension CarPlayManager: CarPlayNavigationDelegate
CarPlayManager is the main object responsible for orchestrating interactions with a Mapbox map on CarPlay.
Messages declared in the CPApplicationDelegate protocol should be sent to this object in the containing application’s application delegate. Implement CarPlayManagerDelegate in the containing application and assign an instance to the delegate property of your CarPlayManager instance.
Note
It is very important you have a singleCarPlayManager instance at any given time. This should be managed by your UIApplicationDelegate class if you choose to supply your accessToken to the CarPlayManager.eventsManager via NavigationEventsManager.init(dataSource:accessToken:mobileEventsManager), instead of the Info.plist.
-
Developers should assign their own object as a delegate implementing the CarPlayManagerDelegate protocol for customization.
Declaration
Swift
public weak var delegate: CarPlayManagerDelegate? -
If set to
true, turn-by-turn directions will simulate the user traveling along the selected route when initiated from CarPlay.Declaration
Swift
public var simulatesLocations: Bool -
A multiplier to be applied to the user’s speed in simulation mode.
Declaration
Swift
public var simulatedSpeedMultiplier: Double { get set } -
A Boolean value indicating whether the phone is connected to CarPlay.
Declaration
Swift
public static var isConnected: Bool -
The events manager used during turn-by-turn navigation while connected to CarPlay.
Declaration
Swift
public let eventsManager: NavigationEventsManager -
The object that calculates routes when the user interacts with the CarPlay interface.
Declaration
Swift
public let directions: Directions -
The styles displayed in the CarPlay interface.
Declaration
Swift
public var styles: [Style] { get set } -
The view controller for orchestrating the Mapbox map, the interface styles and the map template buttons on CarPlay.
Declaration
Swift
public var carPlayMapViewController: CarPlayMapViewController? { get } -
The bar button that exits the navigation session.
Declaration
Swift
public lazy var exitButton: CPBarButton { get set } -
The bar button that mutes the voice turn-by-turn instruction announcements during navigation.
Declaration
Swift
public lazy var muteButton: CPBarButton { get set } -
The bar button that prompts the presented navigation view controller to display the feedback screen.
Declaration
Swift
public lazy var showFeedbackButton: CPMapButton { get set } -
The bar button that shows the selected route overview on the map.
Declaration
Swift
public lazy var userTrackingButton: CPMapButton { get set } -
The main map view displayed inside CarPlay.
Declaration
Swift
public var mapView: NavigationMapView? { get } -
Initializes a new CarPlay manager that manages a connection to the CarPlay interface.
Declaration
Swift
public convenience init(styles: [Style]? = nil, directions: Directions? = nil, eventsManager: NavigationEventsManager? = nil)Parameters
stylesThe styles to display in the CarPlay interface. If this argument is omitted,
DayStyleandNightStyleare displayed by default.directionsThe object that calculates routes when the user interacts with the CarPlay interface. If this argument is
nilor omitted, the sharedDirectionsobject is used by default.eventsManagerThe events manager to use during turn-by-turn navigation while connected to CarPlay. If this argument is
nilor omitted, a standardNavigationEventsManagerobject is used by default. -
Programatically begins a carplay turn-by-turn navigation session.
Precondition
The NavigationViewController must be fully presented at the time of this call.Declaration
Swift
public func beginNavigationWithCarPlay(using currentLocation: CLLocationCoordinate2D, navigationService: NavigationService)Parameters
currentLocationThe current location of the user. This will be used to initally draw the current location icon.
navigationServiceThe service with which to navigation. CarPlayNavigationViewController will observe the progress updates from this service.
-
Declaration
Swift
public func carPlayNavigationViewControllerDidDismiss(_ carPlayNavigationViewController: CarPlayNavigationViewController, byCanceling canceled: Bool)
Install in Dash
CarPlayManager Class Reference