Question

I'd love to find out when a Bluetooth device (earpiece, microphone, car audio connection, etc.) becomes available so I can change the audio options in my app's UI.

As of iOS 6, there are notifications which are supposed to fire when interruptions and route changes happen. The notification that looks potentially the most useful is the AVAudioSessionRouteChangeNotification one, where the notification's userInfo dictionary will come with a AVAudioSessionRouteChangeReasonKey which gives useful info like AVAudioSessionRouteChangeReasonNewDeviceAvailable and AVAudioSessionRouteChangeReasonOldDeviceUnavailable.

Unfortunately, if my audio session starts off without using Bluetooth (e.g. using the built-in microphone or a wired headset instead), I never hear about any Bluetooth audio device becoming available or unavailable via these route change notifications, irregardless of which device I turn on and off and make available.

Another option (which I haven't tried yet) is AVAudioSessionDelegate, which had a protocol method named inputIsAvailableChanged:. I use the word had because the protocol is fully deprecated as of iOS 6 hence the introduction of the above notifications.

Would anyone know how to do this right (where I get reliable notifications of a Bluetooth device becoming available or unavailable), or if there are other options I can consider?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top