$ npm install react-native-nearby --save
- Initiate a podfile in case you don't have a workspace yet
cd ios/ && pod init - Add
pod 'NearbyMessages'to the podfile located atPodfile - Run
pod installto install the dependencies
$ react-native link react-native-nearby
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-nearbyand addRNNearby.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNNearby.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNNearbyPackage;to the imports at the top of the file - Add
new RNNearbyPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-nearby' project(':react-native-nearby').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-nearby/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-nearby')
- In Visual Studio add the
RNNearby.slninnode_modules/react-native-nearby/windows/RNNearby.slnfolder to their solution, reference from their app. - Open up your
MainPage.csapp
- Add
using Nearby.RNNearby;to the usings at the top of the file - Add
new RNNearbyPackage()to theList<IReactPackage>returned by thePackagesmethod
import RNNearby from 'react-native-nearby';RNNearby.subscribe();The following events can be emitted when subscribing.
| Event name | Notes |
|---|---|
| RNNearby_FOUND | |
| RNNearby_LOST | |
| RNNearby_SIGNAL_CHANGE | Android only |
| RNNearby_DISTANCE_CHANGE | Android only |
RNNearby.unsubscribe();