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
  • 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.

  • Allows to preview routes for a specific RouteResponse object.

    Declaration

    Swift

    @available(*, deprecated, renamed: "previewRoutes(for:﹚")
    public func previewRoutes(for routeResponse: RouteResponse)

    Parameters

    routeResponse

    RouteResponse object, containing selection of routes that will be previewed.

  • Allows to preview routes for a specific IndexedRouteResponse object.

    Declaration

    Swift

    public func previewRoutes(for indexedRouteResponse: IndexedRouteResponse)

    Parameters

    indexedRouteResponse

    IndexedRouteResponse object, containing selection of routes that will be previewed.

  • Allows to cancel routes preview on CarPlay .

    Declaration

    Swift

    public func cancelRoutesPreview()