Skip to content

MohammadAlderson/react-native-proximity

 
 

Repository files navigation

IMPORTANT

This package is a wrapper for the original react-native-proximity package that solve gradle issue

react-native-proximity

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.

Getting Started

  • Install the library
npm install --save react-native-proximity-custom
  • Link the library
react-native link react-native-proximity-custom

Usage

Import the library

import Proximity from 'react-native-proximity-custom';

addListener(callback)

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.

componentDidMount(){
 Proximity.addListener(this._proximityListener);
},

/**
 * State of proximity sensor
 * @param {object} data
 */
 _proximityListener(data) {
   this.setState({
     proximity: data.proximity,
     distance: data.distance // Android-only 
   });
 },

removeListener(callback)

componentWillUnmount() {
  Proximity.removeListener(this._proximityListener);
},

About

📱 A React Native wrapper that provides access to the proximity sensor on iOS and Android.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 55.4%
  • Objective-C 19.6%
  • JavaScript 15.1%
  • Ruby 9.9%