react-native-volume-listen
Getting started
$ yarn add react-native-volume-listen
Mostly automatic installation
$ react-native link react-native-volume-listen
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-volume-listen
and addRNVolumeListen.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNVolumeListen.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.RNVolumeListenPackage;
to the imports at the top of the file - Add
new RNVolumeListenPackage()
to the list returned by thegetPackages()
method
-
Append the following lines to
android/settings.gradle
:include ':react-native-volume-listen' project(':react-native-volume-listen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-volume-listen/android')
-
Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-volume-listen')
-
Important
- Add
import android.view.KeyEvent;
andimport com.reactlibrary.RNVolumeListenModule;
to the imports at top of the file MainActivity.java - Append the following lines to MainActivity class
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return RNVolumeListenModule.onKeyDownEvent(keyCode, event); }
- Add
Usage
;;; // TODO: What to do with the module? { // return UP or DOWN console } { //return current volume (0 -> 1) console } { return <View style=flex: 1> <VolumeListen onVolumePress=thisonVolumePress onChangeVolume=thisonChangeVolume // Only IOS /> </View> }