Carplay连接/断开事件?

时间:2018-10-09 09:32:36

标签: ios swift carplay

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

1 个答案:

答案 0 :(得分:1)

您是否遵循了这些步骤?

  1. 将相应的记录添加到项目的权利文件中:com.apple.developer.carplay-maps类型的Boolean,其值为YES
  2. Request from Apple corresponding permission
  3. 使您的AppDelegate确认遵守CPApplicationDelegate协议
  4. 实施以下方法:

    /**
     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