You can not. What you can do is check the playback route. The problem is that your car speakers will be HeadsetBT. This is the code that I use in my application.
// create and set up the audio session AVAudioSession* audioSession = [AVAudioSession sharedInstance]; [audioSession setDelegate:self]; [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: nil]; [audioSession setActive: YES error: nil]; // set up for bluetooth microphone input UInt32 allowBluetoothInput = 1; OSStatus stat = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof (allowBluetoothInput), &allowBluetoothInput ); NSLog(@"status = %x", stat); // problem if this is not zero // check the audio route UInt32 size = sizeof(CFStringRef); CFStringRef route; OSStatus result = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &size, &route); NSLog(@"route = %@", route); // if bluetooth headset connected, should be "HeadsetBT" // if not connected, will be "ReceiverAndMicrophone"
Teddy source share