Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carplay connect/disconnect events?

Tags:

ios

swift

carplay

Is there a way to detect in an app if the phone was connected/disconnected to/from the car using Carplay? Can't seem to find any documentation regarding it. I'm thinking of some system event like that I could monitor.

like image 210
weuhi Avatar asked Nov 07 '22 01:11

weuhi


1 Answers

Have you followed these steps?

  1. Add corresponding record to your project's Entitlements file: com.apple.developer.carplay-maps type of Boolean with value YES
  2. Request from Apple corresponding permission
  3. Make your AppDelegate confirm to CPApplicationDelegate protocol
  4. Implement 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;
    

Please, check this Documentation link and this WWDC 2018 Carplay Session

like image 160
Aleksey Potapov Avatar answered Nov 25 '22 11:11

Aleksey Potapov