CarPlayManager
@available(iOS 12.0, *)
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 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
initializer, instead of the Info.plist.
-
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
-
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
public let directions: Directions
-
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
currentLocation
The current location of the user. This will be used to initally draw the current location icon.
navigationService
The 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
public convenience init(styles: [Style]? = nil, directions: Directions? = nil, eventsManager: NavigationEventsManager? = nil)
Parameters
styles
The styles to display in the CarPlay interface. If this argument is omitted,
DayStyle
andNightStyle
are displayed by default.directions
The object that calculates routes when the user interacts with the CarPlay interface. If this argument is
nil
or omitted, the sharedDirections
object is used by default.eventsManager
The events manager to use during turn-by-turn navigation while connected to CarPlay. If this argument is
nil
or omitted, a standardNavigationEventsManager
object 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
NavigationMapView
displayed 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 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
destination
A final destination
Waypoint
.completionHandler
A closure to be executed when the calculation completes.
-
Allows to preview routes for a list of
Waypoint
objects.Declaration
Swift
public func previewRoutes(between waypoints: [Waypoint], completionHandler: @escaping CompletionHandler)
Parameters
waypoints
A list of
Waypoint
objects.completionHandler
A 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
routeOptions
A
RouteOptions
object, which specifies the criteria for results returned by the Mapbox Directions API.completionHandler
A closure to be executed when the calculation completes.
-
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, shouldPresentArrivalUIFor waypoint: Waypoint) -> Bool
-
Declaration
Swift
public func carPlayNavigationViewControllerDidDismiss(_ carPlayNavigationViewController: CarPlayNavigationViewController, byCanceling canceled: Bool)
-
Declaration
Swift
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager)
-
Declaration
Swift
public func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager)