I’m working on an app that does NOT support Carplay but I wonder if it’s possible to detect if the device is connected to Carplay so I can add some logic on top of it?
Any insights or documentations are greatly appreciated.
I’m working on an app that does NOT support Carplay but I wonder if it’s possible to detect if the device is connected to Carplay so I can add some logic on top of it?
Any insights or documentations are greatly appreciated.
2
Answers
It is possible to detect when a device is connected to Carplay using the UIScreen class in iOS. Even though your app does not support Carplay, you can still detect the presence of a Carplay screen and take action based on that information.
}
Yes, you can detect if your phone is connected to CarPlay (without relaying on which screen is open in the application). You can use AVAudioSession to check what are the current audio inputs on the device. When you connect to CarPlay, you get a new audio input available which name is CarPlay. It works regardless the app state, whether it’s in the foreground or background.
Here’s the example code: