:iphone: A React Native wrapper that provides access to the proximity sensor on iOS and Android.
A React Native wrapper that provides access to the state of the proximity sensor for iOS and Android.
Usage of react-native-proximity and scrollview.
shell npm install --save react-native-proximity
shell react-native link react-native-proximity
Import the library
import Proximity from 'react-native-proximity';
The callback function returns an object with proximity and distance properties. If proximity is true, it means the device is close to an physical object. distance is only supported in Android. ```javascript componentDidMount(){ Proximity.addListener(this._proximityListener); },
/** * State of proximity sensor * @param {object} data */ _proximityListener(data) { this.setState({ proximity: data.proximity, distance: data.distance // Android-only }); }, ```
componentWillUnmount() { Proximity.removeListener(this._proximityListener); },