我正在为 CarPlay 开发导航应用程序,在 iOS 12 中有两种来自 CPApplicationDelegate 的方法来检测 CarPlay 是否开启:
func application(_ application: UIApplication, didConnectCarInterfaceController interfaceController: CPInterfaceController, to window: CPWindow)
Run Code Online (Sandbox Code Playgroud)
和
func application(_ application: UIApplication, didDisconnectCarInterfaceController interfaceController: CPInterfaceController, from window: CPWindow)
Run Code Online (Sandbox Code Playgroud)
在 iOS 13 中,这些方法已被弃用,Apple 提供了新的委托:CPTemplateApplicationSceneDelegate
我尝试将这个新委托 CPTemplateApplicationSceneDelegate 连接到我的服务,该服务提供 CarPlay 的所有操作,但我认为可以帮助我的功能是:
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何检测 CarPlay 是否已连接,以及如何为在新 iOS 13 CarPlay 的一个窗口中启动的 CarPlay 提供操作。