CarPlayManager
public class CarPlayManager : NSObject
extension CarPlayManager: CPApplicationDelegate
extension CarPlayManager: CPInterfaceControllerDelegate
extension CarPlayManager: CPMapTemplateDelegate
extension CarPlayManager: CarPlayNavigationViewControllerDelegate
extension CarPlayManager: CarPlayMapViewControllerDelegate
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 single CarPlayManager 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 initializer, instead of the Info.plist.
Important
CarPlayManager view will start a Free Drive session by default when CarPlay interface is connected. You can change default behavior using CarPlayManager.startFreeDriveAutomatically property. For more information, see the “Pricing” guide.
-
A controller that manages the templates for constructing a scene’s user interface.
Declaration
Swift
public fileprivate(set) var interfaceController: CPInterfaceController? { get } -
Main window for content, presented on the CarPlay screen.
Declaration
Swift
public fileprivate(set) var carWindow: UIWindow? { get } -
A template that displays a navigation overlay on the map.
Declaration
Swift
public fileprivate(set) var mainMapTemplate: CPMapTemplate? { get } -
A Boolean value indicating whether the phone is connected to CarPlay.
Declaration
Swift
public static var isConnected: Bool
-
Controls whether
CarPlayManagerstarts a Free Drive session automatically on map load.If you set this property to false, you can start a Free Drive session using
CarPlayMapViewController.startFreeDriveNavigation()method. For example:carPlayManager.carPlayMapViewController?.startFreeDriveNavigation()Declaration
Swift
public var startFreeDriveAutomatically: Bool -
Developers should assign their own object as a delegate implementing the CarPlayManagerDelegate protocol for customization.
Declaration
Swift
public weak var delegate: CarPlayManagerDelegate? -
UIViewController, which provides a fully-featured turn-by-turn navigation UI for CarPlay.Declaration
Swift
public fileprivate(set) weak var carPlayNavigationViewController: CarPlayNavigationViewController? { get } -
Property, which contains type of
CarPlayNavigationViewController.Declaration
Swift
public let carPlayNavigationViewControllerType: CarPlayNavigationViewController.Type -
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
@available(*, deprecated, message: "Use `routingProvider` instead. If car play manager was not initialized using `Directions` object - this property is unused and ignored.") public lazy var directions: Directions { get set } -
RoutingProvider, used to create a route during refreshing or rerouting.Declaration
Swift
@available(*, deprecated, message: "Use `customRoutingProvider` instead. This property will be equal to `customRoutingProvider` if that is provided or a `MapboxRoutingProvider` instance otherwise.") public lazy var routingProvider: RoutingProvider { get set } -
Custom
RoutingProvider, used to create a route during refreshing or rerouting.If set to
nil- default Mapbox implementation will be used.Declaration
Swift
public var customRoutingProvider: RoutingProvider? -
Returns current
CarPlayActivity, which is based on currently presentCPTemplate. In case ifCPTemplatewas not created byCarPlayManagercurrentActivitywill be assigned tonil.Declaration
Swift
public private(set) var currentActivity: CarPlayActivity? { get } -
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.
-
Initializes a new CarPlay manager that manages a connection to the CarPlay interface.
Declaration
Swift
@available(*, deprecated, renamed: "init(styles:customRoutingProvider:eventsManager:carPlayNavigationViewControllerClass:﹚") 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. -
Initializes a new CarPlay manager that manages a connection to the CarPlay interface.
Declaration
Swift
@available(*, deprecated, renamed: "init(styles:customRoutingProvider:eventsManager:﹚") public convenience init(styles: [Style]? = nil, routingProvider: RoutingProvider, eventsManager: NavigationEventsManager? = nil)Parameters
stylesThe styles to display in the CarPlay interface. If this argument is omitted,
DayStyleandNightStyleare displayed by default.routingProviderThe object that calculates routes when the user interacts with the CarPlay interface.
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. -
Initializes a new CarPlay manager that manages a connection to the CarPlay interface.
Declaration
Swift
public convenience init(styles: [Style]? = nil, customRoutingProvider: RoutingProvider? = nil, eventsManager: NavigationEventsManager? = nil)Parameters
stylesThe styles to display in the CarPlay interface. If this argument is omitted,
DayStyleandNightStyleare displayed by default.customRoutingProviderThe object that customizes routes calculation when the user interacts with the CarPlay interface.
nilvalue corresponds to default behavior.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.
-
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 main
NavigationMapViewdisplayed inside CarPlay.Declaration
Swift
public var navigationMapView: NavigationMapView? { get }
-
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 }
-
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 brings alternative routes selection during navigation.
Declaration
Swift
public lazy var alternativeRoutesButton: 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 }
-
Calculates routes to the given destination using the Mapbox Directions API and previews them on a map.
Upon successful calculation a new template will be pushed onto the template navigation hierarchy.
Declaration
Swift
public func previewRoutes(to destination: Waypoint, completionHandler: @escaping CompletionHandler)Parameters
destinationA final destination
Waypoint.completionHandlerA closure to be executed when the calculation completes.
-
Allows to preview routes for a list of
Waypointobjects.Declaration
Swift
public func previewRoutes(between waypoints: [Waypoint], completionHandler: @escaping CompletionHandler)Parameters
waypointsA list of
Waypointobjects.completionHandlerA closure to be executed when the calculation completes.
-
Calculates routes satisfying the given options using the Mapbox Directions API and previews them on a map.
Declaration
Swift
public func previewRoutes(for options: RouteOptions, completionHandler: @escaping CompletionHandler)Parameters
routeOptionsA
RouteOptionsobject, which specifies the criteria for results returned by the Mapbox Directions API.completionHandlerA closure to be executed when the calculation completes.
-
Allows to preview routes for a specific
RouteResponseobject.Declaration
Swift
@available(*, deprecated, renamed: "previewRoutes(for:﹚") public func previewRoutes(for routeResponse: RouteResponse)Parameters
routeResponseRouteResponseobject, containing selection of routes that will be previewed. -
Allows to preview routes for a specific
IndexedRouteResponseobject.Declaration
Swift
public func previewRoutes(for indexedRouteResponse: IndexedRouteResponse)Parameters
indexedRouteResponseIndexedRouteResponseobject, containing selection of routes that will be previewed. -
Allows to cancel routes preview on CarPlay .
Declaration
Swift
public func cancelRoutesPreview()
-
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, waypointCircleLayerWithIdentifier identifier: String, sourceIdentifier: String) -> MapboxMaps.CircleLayer? -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, waypointSymbolLayerWithIdentifier identifier: String, sourceIdentifier: String) -> SymbolLayer? -
Declaration
Swift
public func carPlayNavigationViewControllerWillDismiss(_ carPlayNavigationViewController: CarPlayNavigationViewController, byCanceling canceled: Bool) -
Declaration
Swift
public func carPlayNavigationViewControllerDidDismiss(_ carPlayNavigationViewController: CarPlayNavigationViewController, byCanceling canceled: Bool) -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, shouldPresentArrivalUIFor waypoint: Waypoint) -> Bool -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager) -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, routeLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, routeCasingLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, routeRestrictedAreasLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? -
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, willAdd layer: Layer) -> Layer?
-
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, guidanceBackgroundColorFor style: UIUserInterfaceStyle) -> UIColor? -
Declaration
Swift
public func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager) -
Declaration
Swift
public func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController, routeLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? -
Declaration
Swift
public func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController, routeCasingLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? -
Declaration
Swift
public func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController, routeRestrictedAreasLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? -
Declaration
Swift
public func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController, willAdd layer: Layer) -> Layer?
Install in Dash
CarPlayManager Class Reference