Hi All,
Just would like to know: is there any way to programmatically determine if an iPhone is connected (via USB or Bluetooth) to the CarPlay system? Thanks in advance.
Hi All,
Just would like to know: is there any way to programmatically determine if an iPhone is connected (via USB or Bluetooth) to the CarPlay system? Thanks in advance.
Implement the MPPlayableContentDelegate function:
func playableContentManager(_ contentManager: MPPlayableContentManagerContext, didUpdate context: MPPlayableContentManagerContext)Then check context.endpointAvailable, true == CarPlay connected
That will be called when device connects/disconnects from CarPlay.
You can also check if AVAudioSession.sharedInstance().currentRoute.outputs.first.portType == AVAudioSessionPortCarAudio
Thanks for your response, deanfromcelebration.
I did implement the delegate method -playableContentManager:didUpdateContext: and it works. Still have another question: beside connecting/dis-connecting to the CarPlay system, is there any other event(s) that will trigger this delegate method to get called? Thanks again.
I've only seen it called when connecting/disconnecting from CarPlay.
Just curious: if I use Bluetooth to connect my iPhone with the CarPlay system, will the delegate method -playableContentManager:didUpdateContext: get called? Thanks again.