weuhi
weuhi

Reputation: 183

Carplay connect/disconnect events?

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.

Upvotes: 5

Views: 3209

Answers (1)

Aleksey Potapov
Aleksey Potapov

Reputation: 3783

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

Upvotes: 1

Related Questions