Library for performing haptic feedback in React Native
Library exports methods:
Use impact feedback to indicate that an impact has occurred. For example, you might trigger impact feedback when a user interface object collides with another object or snaps into place.
A collision between large, heavy user interface elements.
A collision between moderately sized user interface elements.
A collision between small, light user interface elements.
Use notification feedback to communicate that a task or action has succeeded, failed, or produced a warning of some kind.
A notification feedback type, indicating that a task has failed.
A notification feedback type, indicating that a task has completed successfully.
A notification feedback type, indicating that a task has produced a warning.
Use selection feedback to communicate movement through a series of discrete values.
import RNHaptics from 'react-native-haptics';
const { notification, impact, selection } = RNHaptics;
notification("error")
$ yarn add react-native-haptics
$ react-native link react-native-haptics
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-haptics
and addRNHaptics.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNHaptics.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.osdnk.haptics.RNHapticsPackage;
to the imports at the top of the file - Add
new RNHapticsPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-haptics' project(':react-native-haptics').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-haptics/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-haptics')
In order to develop simply modify files by opening the Example
app via Android Studio or Xcode. Generally, it means that modifications refer to node_modules
files. If you wish for your changes to be placed in the main folder in order to commit them use:
./copyFromNodeModules.sh
If you wish to copy files to node_modules
without installing dependencies you're to use:
./putIntoNodeModules.sh