react-native-webrtc / react-native-incall-manager

Handling media-routes/sensors/events during a audio/video chat on React Native
ISC License
547 stars 191 forks source link

Audio not routing to speaker by default when the auto settings are true #220

Closed khushal87 closed 5 months ago

khushal87 commented 1 year ago

In my application, I have the media set to audio and auto is true, which means I am using the Automatic behaviour, but as soon as I start the call, my audio is not routed through the speaker but through an earpiece by default and it doesn't change even if I take the proximity benefits and bring my phone near to my ears.

My code looks like this:

InCallManager.start({ media: 'audio', auto: true });
    // Added this because of https://github.com/react-native-webrtc/react-native-incall-manager/issues/82#issuecomment-385241109
    if (Platform.OS === 'ios') {
      NativeModules.InCallManager.addListener('Proximity');
    }
    DeviceEventEmitter.addListener('Proximity', function (data) {
      if (data.isNear) {
        InCallManager.setSpeakerphoneOn(false);
      } else {
        InCallManager.setSpeakerphoneOn(true);
      }
    });

Note: Routing through Bluetooth devices works fine, but the speaker isn't working.

Expected behaviour: The audio should be routed through the speaker if no Bluetooth device is connected, and the audio should only route through the earpiece if it's brought near the ears, not by default.