有没有一种方法可以在应用程序中检测到手机是否使用Carplay连接/断开与汽车的连接? 似乎找不到任何相关的文档。 我在考虑一些系统事件,例如我可以监控。
com.apple.developer.carplay-maps
type of Boolean
with value YES
CPApplicationDelegate
protocolImplement the next methods:
/**
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;
applicationDidFinishLaunching
中无条件地实现它,只是不会被使用。然而,如果您非常坚持这样做,一个值得的方法可能是监听音频输出路由的变化 - 这可能会在连接/断开 CarPlay 时被触发。 - DrMickeyLauer