williambout / react-native-proximity

:iphone: A React Native wrapper that provides access to the proximity sensor on iOS and Android.
MIT License
211 stars 69 forks source link

Getting error while integrating this package. #26

Open vivekshah-zymr opened 4 years ago

vivekshah-zymr commented 4 years ago

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

geraintwhite commented 4 years ago

@grit96/react-native-proximity is my fork of the project that includes https://github.com/williambout/react-native-proximity/pull/13 and https://github.com/williambout/react-native-proximity/pull/20 to make the module work properly.

vivekshah-zymr commented 4 years ago

Ok @grit96 . Do you have any idea why I am getting the above errors?

geraintwhite commented 4 years ago

I use the module with react-native 0.59.x but there are some other pull requests relating to 0.60+ support which you might need to implement.

baselbj commented 4 years ago

@grit96/react-native-proximity

I am using your fork but still facing the sam issue