CarPlay Application (iOS 13.1.1) - `openInMaps`

A user is able to request directions to a specific location using our CarPlay application. We are utilising Maps to achieve this functionality:


let placemark = MKPlacemark(coordinate: item.coordinate)
let mapitem = MKMapItem(placemark: placemark)
let options = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving]
mapitem.name = item.mainTitle
if !mapitem.openInMaps(launchOptions: options) {
...
} else {
...
}


This code worked well before iOS 13. It opened the Maps app with directions on the head unit. CarPlay application mirrored the iPhone content. However, because the CarPlay is now decoupled from the actual on-screen content of the iPhone, we can't find a way to force the system to open the Maps app in CarPlay instead of the phone. Does anybody know a way to achieve this?

Replies

Same issue here. Without a solution, a driver now has to touch at least one additional icon to display the map in CarPlay. This is a downside to decoupling CarPlay screen from iPhone screen. A programmatic way to force the switch to Maps would be good.

You need to use a different instance method of MKMapItem called openInMaps(launchOptions:from:completionHandler:).

This method allows you to pass in the CarPlay scene as an argument. This will have Maps open in CarPlay and not on the phone.

Hi, I try to use openInMaps(launchOptions, from: UIScene , completionHandler:...) to open the map in carplay and not in iphone.

But It returned an error when I add the "UIScene" and without it is opened in the iphone on simulator but no reaction on carplay

Can anyone share an explample that works in "carplay" using openInMaps()

Add a Comment