I need to catch sound volume button press inside my react-native application. Couldn't find anything in docs.
You could create a native module as per FuzzyTree's comment however if you want something that's ready out of the box you could use https://github.com/IFours/react-native-volume-slider and make it hidden. The onValueChange callback is called upon the iOS device volume controls being changed.
Another idea could be to look into the aforementioned module and just take out what you need to form a new module and publish it for the benefit of everyone.
You can use react-native-system-setting
package with addVolumeListener
listener. Something like this
componentDidMount() {
// listen the volume changing
this.volumeListener = SystemSetting.addVolumeListener(data => {
// your action here
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With