Detecting CarPlay connection when app wakes in background via geofence

Our iOS app supports CarPlay capability with the Driving task. The app is also configured to wake in the background on geofence entry or exit events, even from a terminated (killed) state.

We would like to understand how to detect whether CarPlay is connected to the iPhone when the app wakes up or runs in the background. In this case, the CarPlay app is not actively running in the Car infotainment system foreground.

Requirement: The app should perform a background task only when CarPlay is connected, including when launched in the background or from a killed state due to a geofence trigger.

Could you please advise on the recommended way or API to determine CarPlay connection status in this background scenario?

Thanks for the support!

You can determine if CarPlay is connected via UIWindowSceneDelegate

 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

Will be called when a connection is being established.

Then you can track

func sceneDidDisconnect(_ scene: UIScene) 

To also determine if a scene has been disconnected.

Hopefully this helps.

Rico
Car Experience - Software Engineer

Detecting CarPlay connection when app wakes in background via geofence
 
 
Q