Skip to content

devicesChangedEventStream` on iOS does not emit a device removed event when Bluetooth disconnects #184

Description

@ChiragLiveu

Hi,

I'm using the latest version of the audio_session package on both iOS and Android.

I noticed that devicesChangedEventStream works correctly when a Bluetooth device is connected. The stream emits an event, and devicesAdded contains the connected device.

However, when the Bluetooth device is disconnected, no event is emitted. As a result, devicesRemoved is never populated, and I have no way to detect that the Bluetooth device has been removed.

Is this expected behaviour on iOS, or is it a bug? If this is a known limitation, could you please suggest a workaround to detect Bluetooth device disconnection?

Here is my code:

audioSession.devicesChangedEventStream.listen((event) {
  print('Devices added: ${event.devicesAdded}');
  print('Devices removed: ${event.devicesRemoved}');

  Future.delayed(const Duration(milliseconds: 1000), () {
    updateAudioSwitchList(audioSession);
  });
});

Expected behaviour

  • An event should be emitted when a Bluetooth device is disconnected.
  • devicesRemoved should contain the disconnected device so that the application can update the available audio routes.

Actual behaviour

  • An event is emitted only when the Bluetooth device is connected.
  • No event is received when the Bluetooth device is disconnected.

I would appreciate any guidance or workaround for handling Bluetooth disconnection on iOS.

Thank you for your time and support!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions