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

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

setSpeakerPhoneOn not working for incoming call Android #212

Open easyscripter opened 1 year ago

easyscripter commented 1 year ago

When il make incoming call and accept . il try setSpeakerPhoneOn but its not working. But for outgoing call its working. I use sip js react-native webrtc and react native incall manager.

const onAccepted = (data: any) => { if (data && data.route === 'incoming') { setCallActive(true); setIsCalling(false); InCallManager.start({media: 'audio'}); RNCallKeep.setCurrentCallActive(currentCallUUID); } else if (data && data.route === 'outgoing') { RNCallKeep.setCurrentCallActive(currentCallUUID); setIsCalling(false); InCallManager.stopRingback(); } }

const handleSpeaker = (isSpeaker: boolean) => { InCallManager.setSpeakerphoneOn(isSpeaker); }

edritech93 commented 1 year ago

same issue for me I use Android 13

icc-guerrero commented 1 year ago

Same here. Is a Samsung device @edritech93?

mariouzae commented 1 year ago

Tested with Samsung and Oppo both Android 12 and it didn't work.

Neither setForceSpeakerphoneOn nor setSpeakerphoneOn is working. Looking at the logs, I see it update the defaultAudioMode but it didn't route the audio to the phone speaker.

setForceSpeakerphoneOn() flag: 1 updateAudioDeviceState: wired headset=false, BT state=HEADSET_UNAVAILABLE Device status: available=[EARPIECE, SPEAKER_PHONE], selected=SPEAKER_PHONE, user selected=SPEAKER_PHONE updateAudioDeviceState done

I'm calling the .start before trying to change the audio to the speaker.

mariouzae commented 1 year ago

If you are using RN-InCallManager in conjunction with RN-CallKeep, remember to call RNCallKeep.toggleAudioRouteSpeaker() after calling setForceSpeakerphoneOn(), for some reason the RNCallKeep has control if you have called the RNCallKeep.startCall() first.

wilmxre commented 1 year ago

hey @mariouzae, does this work for you 100% of the time?

elangovansword commented 1 year ago

For me audio switch worked after adding permission in AndroidManifest.xml file

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />