The library for switch audio output source in your device for React Native
npm install react-native-switch-audio-output$ npm install react-native-switch-audio-output --save
cd ios && pod install && cd ..
$ react-native link react-native-switch-audio-output && cd ios && pod install && cd ..
javascript
import RNSwitchAudioOutput from 'react-native-switch-audio-output';// check the audio source is speaker or not (Android only) return boolean
RNSwitchAudioOutput.isSpeakerphoneOn(res => {
});
/*
switch audio source to speaker or headphone
*/
// switch to speakerphone
RNSwitchAudioOutput.selectAudioOutput(RNSwitchAudioOutput.AUDIO_SPEAKER)
// switch to headphone
RNSwitchAudioOutput.switchAudioOutput(RNSwitchAudioOutput.AUDIO_HEADPHONE)
``