有没有一种方法可以在应用程序中使用Carplay检测手机是否已与汽车连接/断开连接?
似乎找不到有关它的任何文档。
我正在考虑一些可以监视的系统事件。

最佳答案

您是否遵循了这些步骤?

  • 将相应的记录添加到您的项目的权利文件中:com.apple.developer.carplay-maps类型的Boolean的值为YES
  • Request from Apple corresponding permission
  • 使您的AppDelegate确认使用CPApplicationDelegate协议(protocol)
  • 实现以下方法:
    /**
     The CarPlay screen has connected and is ready to present content.
    
     Your app should create its view controller and assign it to the @c rootViewController property
     of this window.
    
     @note It is the responsibility of the delegate to maintain a reference to the interface controller beyond the scope of this method.
     */
    - (void)application:(UIApplication *)application didConnectCarInterfaceController:(CPInterfaceController *)interfaceController toWindow:(CPWindow *)window;
     /**
     The CarPlay screen has disconnected.
      */
    - (void)application:(UIApplication *)application didDisconnectCarInterfaceController:(CPInterfaceController *)interfaceController fromWindow:(CPWindow *)window;
    

  • 请检查此Documentation linkthis WWDC 2018 Carplay Session

    关于ios - Carplay连接/断开事件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52717721/

    10-12 14:35