README
react-native-benibeacon
Getting started
$ npm install react-native-benibeacon --save
Mostly automatic installation
$ react-native link react-native-benibeacon
Manual installation
Android
- Append the following lines to
android/settings.gradle
:include ':react-native-benibeacon' project(':react-native-benibeacon').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-benibeacon/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(':react-native-benibeacon')
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.mhandharbeni.benibeacon.RNBenibeaconPackage;
to the imports at the top of the file - Add
new RNBenibeaconPackage()
to the list returned by thegetPackages()
method
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.mhandharbeni.benibeacon.RNBenibeaconModule;
to the imports at the top of the file - Add
RNBenibeaconModule.checkPermissions(MainActivity.this, getApplicationContext());
to theonCreate
method
Usage
import RNBenibeacon from 'react-native-benibeacon';
// TODO: What to do with the module?
RNBenibeacon;
// start services
RNBenibeacon.startServices()
// force start services
RNBenibeacon.forceStartServices()
// get list beacon
RNBenibeacon.getListBeacon()
Example
async getBeacon(){
return await RNBenibeacon.getListBeacon()
}
async startService(){
return await RNBenibeacon.startServices()
}
async forceStartService(){
return await RNBenibeacon.forceStartServices()
}
// getting data beacon
let beacon = this.getBeacon();
beacon.then((items)=>{
console.log(items);
})
.catch((error)=>{
console.log(items);
});