I have navigation app and now I'm developing CarPlay Dashboard. I can't launch InterfaceController after click button in CPDashboard.
My button code:
let searchButton = CPDashboardButton(titleVariants: ["Find"], subtitleVariants: ["place"], image: searchImage) { [weak self] (_) in
self?.openSearchView()
}
After button tap, func openSearchView() is called, but view still stay in dashboard.
There is no info in docs, how can we switch between view (interface controller <-> dashboard controller)
Not sure this is the right way, but ther is no mention about this, not even the official sample app does it. But you can achieve it by calling open(_, options:, completionHandler)
on dashboardScene.
Like this
dashboardController.shortcutButtons = [CPDashboardButton(titleVariants: ["Find"], subtitleVariants: ["place"], image: searchImage, handler: { _ in
guard let url = URL(string: "your.app.scheme://whatever/wherever") else { return }
templateApplicationDashboardScene.open(url, options: nil, completionHandler: nil)
})]
This will open the main app and calls open(_, urlContexts:)
on main carplay scene where you can handle that url and react accordingly, like open search ar whatever.