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