GithubHelp home page GithubHelp logo

williambout / react-native-proximity Goto Github PK

View Code? Open in Web Editor NEW
211.0 7.0 69.0 2.55 MB

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

License: MIT License

Objective-C 19.58% JavaScript 15.08% Java 55.43% Ruby 9.91%
react-native proximity-sensor sensor iphone ios android

react-native-proximity's Introduction

npm version

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
  • Link the library
react-native link react-native-proximity

Usage

Import the library

import Proximity from 'react-native-proximity';

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);
},

react-native-proximity's People

Contributors

attilaaronnagy avatar ghsdh3409 avatar izabelajelonek avatar ohtangza avatar williambout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-proximity's Issues

Getting error while integrating this package.

Hello, I want to integrate this package to leverage the proximity feature of the device.
I am checking this on iPhone 6s with 13.3.1, I haven't tried this on android.
Here's my
package.json

"dependencies": {
    "@grit96/react-native-proximity": "^3.0.1",
    "react": "16.11.0",
    "react-native": "0.62.2"
  },

Que-1: Should I use npm react-native-proximity or @grit96/react-native-proximity?

Now after installing I have properly linked this package by react-native link @grit96/react-native-proximity (Got the relevant message for the same on a console.)

App.js


import Proximity from '@grit96/react-native-proximity';

export default class App extends Component {
  componentDidMount() {
     Proximity.addListener(this._proximityListener);
  }
  _proximityListener(data) {
    console.log('In _proximityListener===', data);
  }
  componentWillUnmount() {
     Proximity.removeListener(this._proximityListener);
  }
Other stuff...

This gives me an error on console like,
TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNProximity.proximityEnabled')

I thought it might be due to linking, so I have tried to link this library manually by adding RNProximity.xcodeproj under the Libraries folder in XCode. And added libRNProximity.a under BuildPhase >Link Binary With Libraries, but that gives me an error like 'React/RCTBridge.h' file not found in RNProximity.m file

One more thing, my pod file get updated with this,
pod 'react-native-proximity', :path => '../node_modules/@grit96/react-native-proximity'
But when I try to do pod install, it gives me an error like no .podspec file found at the location '../node_modules/@grit96/react-native-proximity'`. (Even if It's there.)

Can anyone please help me where I am going wrong?
@williambout

Project abandoned?

There are a number of critical pull requests that need merging for this module to work properly (#13 and #20).

What can we do to get these merged @williambout and a new version released?

Perhaps the project needs more maintainers? I'm happy to help out and I'm sure others are too.

getting error

hi there every time i run my react native project getting this error

gj

Fetching tags from Cloud failed

I'm getting this error while using my estimote credentials on my app running with the simulator.

Proximity Observer error: Error Domain=EPXProximityObserverErrorDomain Code=1 "Fetching tags from Cloud failed." UserInfo={NSUnderlyingError=0x6000024a4780 {Error Domain=EstimoteProximitySDK.PersistentTagsRepository.Error Code=2 "When running offline, internet connection is required when starting the observer for the first time."}, NSLocalizedDescription=Fetching tags from Cloud failed., NSLocalizedRecoverySuggestion=Make sure your cloud credentials are correct and you have a valid internet connection. See CloudCredentials for more.}

This is happening using the example app of this repo as well, confirmed that the phone has internet and there's tags on my estimote cloud account.

Android: Error:Execution failed for task ':react-native-proximity:compileReleaseJavaWithJavac'.

Hello, thanks for the great RN module.

I'm able to use in iOS but have an issue with Android.

node_modules/react-native-proximity/android/src/main/java/com/RNProximity/RNProximityPackage.java

Error:(19, 5) error: method does not override or implement a method from a supertype

Error:Execution failed for task ':react-native-proximity:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

Thank you for taking the time to take a look at the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.