Add the shake event on your React Native app, giving to users improved usability. Enjoy!
(works only on real device)
$ npm install react-native-shake-event-ios --save
- Add the
RNShakeEvent.xcodeproj
file to your Xcode project Demo; - Add the
Products/libRNShakeEvent.a
file to Build Phases Demo.
This step is described here: Linking Libraries.
import RNShakeEventIOS from 'react-native-shake-event-ios';
class MyComponent extends React.Component {
componentWillMount() {
RNShakeEventIOS.addEventListener('shake', () => {
console.log('Device shake!');
});
}
componentWillUnmount() {
RNShakeEventIOS.removeEventListener('shake');
}
}
Start listening the shake event and handle a callback function.
Stop to listening the shake event, and is recommended to prevent memory leak.
- Submit here;
- iOS only - For Android version please create new module;
- On debug mode this event also handle the DevMenu, but works fine on production.
MIT © Chessboard Radio Lab