This post is from the WWDC26 CarPlay Q&A.
What's the simplest way to programmatically detect the iPhone is connected to CarPlay? (not necessarily having your app launched)
There is no API available for detecting if CarPlay is connected, but related APIs help with common reasons why an app might want to detect if CarPlay is connected:
- Core Motion's CMMotionActivity
automobilecan be used for detecting if the device is likely to be in a vehicle, including driving scenarios without CarPlay connected. - For apps that appear in CarPlay, the
CPTemplateApplicationSceneDelegatein the CarPlay framework allows the app to determine if their app's template UI in CarPlay is appearing / disappearing as CarPlay connects or disconnects.