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

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

[Feature request] Proximity detector api #70

Open gouxlord opened 6 years ago

gouxlord commented 6 years ago

Hello and thanx for this great plugin !

I have an issue caused on my WebRTC negociation if the screen go black with proximity sensor on Android.

My quickfix was to use video mode with ringback and setForceSpeakerphoneOn to false to have a ringback before webrtc negotiation. As the proximity sensor is enabled when the sound is routed to earpiece anyway since last version. I would need to be able to disable it.

So are you ok if i make a pull request to add this API? (simply make startProximitySensor and stopProximitySensor public and linked to react native)

zxcpoiu commented 6 years ago

I was thought that using a variable as a toggle to determine should we turn screen off or not while proximity is in near state, like add a condition here: https://github.com/zxcpoiu/react-native-incall-manager/blob/master/android/src/main/java/com/zxcpoiu/incallmanager/InCallManagerModule.java#L430

But seems it doesn't work on iOS.

You can make it public but with a _ prefix indicating this is a hidden api with unpredicted behavior. I would not suggest to use hidden API, but I believe in some scenario, it may be necessary.

Go ahead, we'll find out a better way for how to represent api always. To align both iOS and Android as possible.

Just curious, why screen goes to black caused negotiation issue? is that a event not triggered in the background problem?