1

I have navigation app and now I'm developing CarPlay Dashboard. I can't launch InterfaceController after click button in CPDashboard.

enter image description here

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)

1 Answers1

2

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.

anonym
  • 136
  • 5
  • That's it! I did it 3 weeks ago, and forgot write answer here. Thanks for your help ;) – Michael_Gruszka May 10 '21 at 06:16
  • Hi, I have the same issue. However, it does not work for me when using the .open() function. I wrote "my.app.scheme://carplay". That might be the issue? Should it be something specific that I don't know about? And if there is another way, that would be really helpful. "my.app.scheme" being my actual app scheme – Jaafar Mahdi Aug 08 '23 at 17:53