Giter VIP home page Giter VIP logo

react-native-beacons-manager's Introduction

npm npm Gitter

react-native-beacons-manager

logo FOSSA Status

react-native-beacons-manager: add beacon technology in your React Native application for both iOS and Android.

This repository is born to keep alive and up to date these 3 original awesome:

If you want to know more about just have a look at my medium article.

If you want to test with a simulated beacon, there is a useful free application on android: beaconsimulator and MacOS: BeaconEmitter

Install (iOS and Android)

Ensure to have NodeJS >= v6.x.

You must run on real devices (don't forget to active Bluetooth when running).

Mobile Version compatibility:

  • iOS minimum version
    • 8.0
  • Android minimum version
    • 21 (alias LOLLIPOP)

1. get modules

via npm:

npm install react-native-beacons-manager

or via yarn:

yarn add react-native-beacons-manager

2. link to your application

react-native link react-native-beacons-manager

3.a configuration specific to iOS

If you plan to:

  • only range beacons no configuration needed (react-native init already did the job for you), or just check that you already have WhenInUse authorization declared in your info.plist:

    • ios: request when in use authorization
  • monitor then default authorization won't be enough:

    • in your info.plist, add Privacy - Location Always Usage Description key defined (empty value or not. It is better to define a value to a custom / more user-friendly message). ios: request when in use authorization
  • If your Info.plist contains a NSBluetoothPeripheralUsageDescription key, you have to specify an associated text to avoid being rejected.

  • use background mode check this documentation

3.b configuration specific to Android

Nothing (lucky Android πŸ˜„).

Just don't forget to activate

  • Bluetooth service (all android version)
  • Location service (android < 7: beacon detection won't work on android 6 if location service is off)

4. usage

NOTE: If simple examples below don't help you as much as you wanted, check detailed documentation depending on use-case + code samples here

4.a iOS

Simple example

import { DeviceEventEmitter } from 'react-native'
import Beacons from 'react-native-beacons-manager'

// Define a region which can be identifier + uuid,
// identifier + uuid + major or identifier + uuid + major + minor
// (minor and major properties are numbers)
const region = {
    identifier: 'Estimotes',
    uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
};

// Request for authorization while the app is open
Beacons.requestWhenInUseAuthorization();

Beacons.startMonitoringForRegion(region);
Beacons.startRangingBeaconsInRegion(region);

Beacons.startUpdatingLocation();

// Listen for beacon changes
const subscription = DeviceEventEmitter.addListener(
  'beaconsDidRange',
  (data) => {
    // data.region - The current region
    // data.region.identifier
    // data.region.uuid

    // data.beacons - Array of all beacons inside a region
    //  in the following structure:
    //    .uuid
    //    .major - The major version of a beacon
    //    .minor - The minor version of a beacon
    //    .rssi - Signal strength: RSSI value (between -100 and 0)
    //    .proximity - Proximity value, can either be "unknown", "far", "near" or "immediate"
    //    .accuracy - The accuracy of a beacon
  }
);

API

Method Description
requestWhenInUseAuthorization This method should be called before anything else is called. It handles to request the use of beacons while the application is open. If the application is in the background, you will not get a signal from beacons. Either this method or Beacons.requestAlwaysAuthorization needs to be called to receive data from beacons.
requestAlwaysAuthorization This method should be called before anything else is called. It handles to request the use of beacons while the application is open or in the background. Either this method or Beacons.requestWhenInUseAuthorization needs to be called to receive data from beacons.
getAuthorizationStatus This methods gets the current authorization status. While this methods provides a callback, it is not executed asynchronously. The values authorizedAlways and authorizedWhenInUse correspond to the methods requestWhenInUseAuthorization and requestAlwaysAuthorization respectively.
startMonitoringForRegion When starting monitoring for beacons, we need to define a region as the parameter. The region is an object, which needs to have at least two values: identifier and uuid. Additionally, it can also have a major, minor version or both. Make sure to not re-use the same identifier. In that case, we won't get the data for the beacons. The corresponding events are regionDidEnter and regionDidExit.
stopMonitoringForRegion Stops monitoring for beacons. We pass a region as parameter, which has the same shape as the argument we pass in startMonitoringForRegion.
startRangingBeaconsInRegion When ranging for beacons, we need to define a region as the parameter. The region is an object, which needs to have at least two values: identifier and uuid. Additionally, it can also have a major, minor version or both. Make sure to not re-use the same identifier. In that case, we won't get the data for the beacons. The corresponding events are beaconsDidRange. The event will fire in every interval the beacon sends a signal, which is one second in most cases. If we are monitoring and ranging for beacons, it is best to first call startMonitoringForRegion and then call startRangingBeaconsInRegion.
stopRangingBeaconsInRegion Stops ranging for beacons. We pass a region as parameter, which has the same shape as the argument we pass in startRangingBeaconsInRegion.
requestStateForRegion When requesting state for beacons, we need to define a region as the parameter. The region is an object, which needs to have at least two values: identifier and uuid. Additionally, it can also have a major, minor version or both. Make sure to not re-use the same identifier. In that case, we won't get the data for the beacons. The corresponding events are didDetermineState.
startUpdatingLocation This call is needed for monitoring beacons and gets the initial position of the device.
stopUpdatingLocation This method should be called when you don't need to receive location-based information and want to save battery power.
shouldDropEmptyRanges Call this method to stop sending the beaconsDidRange event when the beacon list is empty. This can be useful when listening to multiple beacon regions and can reduce cpu usage by 1-1.5%.
                                                                                                                                                                                                                         |
Event Description
authorizationStatusDidChange This event will be called when authorization changed for receiving data location. PLEASE NOTE: starting a location service will not provide data location until authorization is given by the user ("authorizedAlways" or "authorizedWhenInUse").
beaconsDidRange This event will be called for every region in every beacon interval. If you have three regions you get three events every second (which is the default interval beacons send their signal). When we take a closer look at the parameter of the callback, we get information on both the region and the beacons.
regionDidEnter If the device entered a region, regionDidEnter is being called. Inside the callback the parameter we can use returns an object with a property region that contains the region identifier value as a string. Additionally, we get the UUID of the region through its uuid property.
regionDidExit In the same regionDidEnter is called if the device entered a region, regionDidExit will be called if the device exited a region and we can't get any signal from any of the beacons inside the region. As for the payload, we get a property called region that represents the region identifier and is a string as well as the uuid.
didDetermineState If there is a boundary transition for a region, didDetermineState is being called. Inside the callback the parameter we can use returns an object with a property region that contains the region identifier value as a string. Additionally, we get the UUID of the region through its uuid property.
authorizationDidChange When the user permissions change, for example the user allows to always use beacons, this event will be called. The same applies when the user revokes the permission to use beacons. The payload is a string which can either be: "authorizedAlways", "authorizedWhenInUse", "denied", "notDetermined" or "restricted"

4.b Android

Simple example

import { DeviceEventEmitter } from 'react-native'
import Beacons from 'react-native-beacons-manager'

// Tells the library to detect iBeacons
Beacons.detectIBeacons()

// Start detecting all iBeacons in the nearby
try {
  await Beacons.startRangingBeaconsInRegion('REGION1')
  console.log(`Beacons ranging started succesfully!`)
} catch (err) {
  console.log(`Beacons ranging not started, error: ${error}`)
}

// Print a log of the detected iBeacons (1 per second)
DeviceEventEmitter.addListener('beaconsDidRange', (data) => {
  console.log('Found beacons!', data.beacons)
})

API

Method Description
detectCustomBeaconLayout(parser: string): void Allows the detection of a custom beacon layout. For example detectCustomBeaconLayout('m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24') allows you to detect iBeacons beacons.
detectIBeacons(): void Allows the detection of iBeacons. It's just like calling detectCustomBeaconLayout with the iBeacons layout.
detectEstimotes(): void Allows the detection of Estimote beacons. It's just like calling detectCustomBeaconLayout with the Estimote layout.
checkTransmissionSupported(): promise Checks if the device can use the Bluetooth to detect the beacons.
setForegroundScanPeriod(period: number): void Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons (in foreground). For more info take a look at the official docs
setBackgroundScanPeriod(period: number): void Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons (in background). For more info take a look at the official docs
setBackgroundBetweenScanPeriod(period: number): void Sets the duration in milliseconds spent not scanning between each Bluetooth LE scan cycle when no ranging/monitoring clients are in the foreground. For more info take a look at the official docs
setRssiFilter(filterType: int, avgModifier: number): void Sets the RSSI averaging method. The parameter filterType must be one of the exported constants ARMA_RSSI_FILTER or RUNNING_AVG_RSSI_FILTER. The avgModifier param changes the rate of the averaging function For the ARMA filter it's in the range 0.1-1.0, for the running average it's the filter window in milliseconds. For more info take a look at the docs
setHardwareEqualityEnforced(e: boolean): void Configures whether the bluetoothAddress (mac address) must be the same for two Beacons to be configured equal. This setting applies to all beacon instances in the same process. Defaults to false for backward compatibility. Useful when all the beacons you are working with have the same UUID, major and minor (they are only uniquely identifiable by their mac address), otherwise the module will detect all the beacons as if they were only one. For more info take a look at the official docs
getRangedRegions(): promise Returns a promise that resolves in an array with the regions being ranged.
getMonitoredRegions(): promise Returns a promise that resolves in an array with the regions being monitored.
startMonitoringForRegion({identifier: string, uuid: string, minor: int, major: int}): promise Starts monitoring for beacons. The parameter identifier must be an unique ID. The parameter uuid is optional, it allows you to detect only the beacons with a specific UUID (if null every beacon will be detected). The parameters minor and major are optional, they allow you to monitor only the region of a specific beacon.
startRangingBeaconsInRegion(regionId: string, beaconsUUID: string): promise Starts range scan for beacons. The parameter regionId must be an unique ID. The parameter beaconsUUID is optional, it allows you to detect only the beacons with a specific UUID (if null every beacon will be detected).
startRangingBeaconsInRegion({identifier: string, uuid: string}): promise Starts range scan for beacons. The parameter identifier must be an unique ID. The parameter uuid is optional, it allows you to detect only the beacons with a specific UUID (if null every beacon will be detected). Prefer the use of this method over startRangingBeaconsInRegion(regionId: string, beaconsUUID: string), as this method signature more closely matches the signature for the equivalent iOS method. PLEASE NOTE: to listen EddyStone beacons on iOS, you have to pass an identifier as: EDDY_STONE_REGION_ID, (example: Beacons.startRangingBeaconsInRegion({identifier: 'EDDY_STONE_REGION_ID', ...restOptions})).
stopMonitoringForRegion({identifier: string, uuid: string, minor: int, major: int}): promise Stops the monitoring for beacons.
stopRangingBeaconsInRegion(regionId: string, beaconsUUID: string): promise Stops the range scan for beacons.
stopRangingBeaconsInRegion({identifier: string, uuid: string}): promise Stops the range scan for beacons. Prefer the use of this method over stopRangingBeaconsInRegion(regionId: string, beaconsUUID: string), as this method signature more closely matches the signature for the equivalent iOS method.
requestStateForRegion({identifier: string, uuid: string, minor: int, major: int}): void Retrieves the state of a region asynchronously. The parameter identifier must be an unique ID. The parameter uuid is optional, it allows you to detect only the beacons with a specific UUID (if null every beacon will be detected). The parameters minor and major are optional, they allow you to monitor only the region of a specific beacon.

TODO:

Standardization of iOS and android to make library more coherent:

  • iOS

    • startRangingBeaconsInRegion and startMonitoringForRegion should return promises like android
  • android

    • startRangingBeaconsInRegion should accept an object like iOS and other methods (won't prevent from accepting current parameters: not to break existing)

Improvements or new feature:

  • iOS
    • add support to Eddystone
  • android
    • add support to Eddystone

Donate

Do you use & like react-native-beacons-manager but you don’t find a way to show some love? If yes, please consider donating to support this project. Otherwise, no worries, regardless of whether there is support or not, I will keep maintaining this project. Still, if you buy me a cup of coffee I would be more than happy though πŸ˜„

Support via PayPal

license

The MIT License (MIT)

Copyright (c) 2019 Erwan DATIN

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FOSSA Status

react-native-beacons-manager's People

Contributors

aleksandern avatar ashemah avatar dependabot[bot] avatar dukhanov avatar fishkingsin avatar fossabot avatar jdegger avatar jetako avatar jumpman255 avatar mabakach avatar mackentoch avatar miyabi avatar mynameisfiber avatar nativanando avatar omar-dev avatar organom avatar peterdeka avatar pheromonez avatar relaxedtomato avatar rostislav-simonik avatar saghul avatar seblau avatar spedy avatar timsatterfield avatar trongnd avatar wwwjsw avatar zbettenbuk 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-beacons-manager's Issues

android app crashing when startMonitoringForRegion is called

Version

1.0.1

Platform

Android

OS version

android 7.0

Steps to reproduce

  1. Beacons.detectIBeacons()
  2. Beacons.startMonitoringForRegion({ identifier: 'my-region' })
  3. crash

Expected behavior

should monitor all beacons in that region; according to docs uuid is optional

Actual behavior

crash

Package problem?

Hi,

Thanks for this great repo!

I run npm install react-native-beacons-manager (+ linking), but for some reason, the react-native-beacons-manager.d file lacks the iOS only part (these line are missing), i.e., the file is different than master.

Any idea what might cause this? I do see that I have the latest version installed (1.0.7).

Expo client: undefined is not an object

Version

1.0.4

Platform

Windows10 (PowerShell)

OS version

Android 6.0.1

Steps to reproduce

I started with a fresh installation on Windows 10 and followed the medium article. I used the following node, npm and react native versions:
node: 6.11.1
npm: 3.10.10
react-native-cli: 2.0.1
react-native: 0.45.1
Since I wanted to try the Expo client, I didn't git clone https://github.com/MacKentoch/reactNativeBeaconExample.git but just copied the beaconRangingOnly code into my App.js and changed the export default class name
export default class RNbeaconArticle extends React.Component { ...
I also registered the projects dependencies.

Actual behavior

npm start builds everything fine, but on my Android phone I get the following error:
undefined is not an object (evaluationg 'beaconsAndroid.addParser')
Could it be that the react-native-beacons-manager won't work with Expo?

Add Android RSSI filter customization method

Hi, great job with this library, any plan to introduce the Android's setSampleExpirationMilliseconds method? I think it's just 3 lines of code but could be very useful to enhance the experience during BLE based navigation.
I can fork and implement, even if i'm not an experienced Android dev if you think it could be useful.

Callback requestAlwaysAuthorization

Hey ! Thanks for your wrapper :-) !

I need to know if use allow or decline the pop when he needs to select if he is agree to authorize app to use bluetooth ! How can you do this ?

Thanks :-)

Queation/Bug: getting β€œSending `beaconsDidRange` with no listeners registered.”

I followed the example as is, and everything worked great.

But suddenly, I stopped getting the Beacons detection event, while getting the warning:
β€œSending beaconsDidRange with no listeners registered.”

Any idea what might cause this? I’ve tried everything...

I do have the code part:

var subscription = DeviceEventEmitter.addListener(
  'beaconsDidRange',
  (data) => {
       console.log(data);
  }
);

Version

master

Platform

iOS

OS version

iOS 11.02

Steps to reproduce

As in the example

Ranging while using bluetooth peripherals

Noticed this problem while testing ranging for beacons on iPhone 6s.
When I have my AirPods connected to the phone and data is being transferred between the device and the headphones via BT, the ranging for iBeacons with this library gets very spotty.
It can still detect the beacons here and there, but the signal strength often reports as 0 and accuracy as -1.

This might be the case while using other Bt peripherals too. I'm wondering if this is a problem with the library or a problem with iOS / the device itself. Can someone reproduce the problem?

Version

1.0.4

Platform

iOS

OS version

iOS 10.3.2

Steps to reproduce

  1. Use bluetooth headphones (Apple AirPods in my case)
  2. startMonitoringForRegion
  3. log rssi / accuracy

Expected behavior

Should detect beacons normally.

Actual behavior

Ranging does detect beacons, but the detection is very spotty and RSSI is often reported as "0" and accuracy as "-1".

Monitoring after device reboot?

Version

Any

Platform

iOS

OS version

iOS 10

Steps to reproduce

  1. Open app and run beacon logic
  2. Close app or leave in background
  3. Reboot device
  4. Beacon monitoring / ranging doesn't wake app

Expected behavior

Beacons should monitor/range

Actual behavior

Beacons don't monitor/range. From what i've seen online this should work fine, although maybe there's something in the RN bridging that is losing this functionality for us?

Cannot build an android app

i want to mention that there is no code related to this library in the react native app

Version

1.0.1

Platform

Android

OS version

android 7.0

Steps to reproduce

  1. npm install the module
  2. npm link it
  3. react-native run-android

Expected behavior

Successful build

Actual behavior

Build failure:
error:
package com.mackentoch.beaconsandroid does not exist
import com.mackentoch.beaconsandroid.BeaconsAndroidPackage;

cannot find symbol new BeaconsAndroidPackage(),

Preset "flow"?

I am simply getting an Error that says "Couldn't find preset "flow" relative to directory "/node-modules/react-native-beacons-manager.

Help? :)

iOS monitoring example doesn't work ranging works fine

Version

1.0.7

RN version 49.3

Platform

iOS

OS version

iOS 11

Steps to reproduce

  1. Create default RN project
  2. Paste in monitoring.ios.js, fix up imports, add correct uuid and name, add plist entries
  3. run on ipad with some beacons laying around

Expected behavior

should see 'regionDidEnter' callback

Actual behavior

No beacons seen. The ranging example works fine. Beacons pop right up
I see my exact issue was opened and closed 4 days ago #49 by @prem315, not sure what happened. Its really just a default app with the monitoring.ios.js example code with an updated plist which is here . I added the extra plist entry as xcode told me my app would not run without it.

<key>NSLocationWhenInUseUsageDescription</key>
<string>When in use description here</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Always and when in use Location description here</string>

Receive empty for major and minor in case on Monitoring

Version

1.0.4

Platform

Android

OS version

android 7.0...

Steps to reproduce

Expected behavior

It monitors the UUID and onEnter or onExit event it get the ibeacon with that UUID and major and minor number

Actual behavior

Monitoring base on the UUID , it listens onEnter and get the beacon but always major and minor are empty and it shows 0

regionDidExit & regionDidEnter not firing on iOS

Version

1.0.1

Platform

iOS

OS version

iOS 10

Steps to reproduce

  1. Follow Android example
  2. call Beacons.startMonitoringForRegion(region)
  3. add listeners

Expected behavior

Events fires similar to Android (some delay) for entering/existing a region.

Actual behavior

No events are firing.

Background Mode in Android

Version

1.0.1

Platform

iOS | Android

OS version

iOS 10| android 7.0...

Just wondering if you have a date for when the android background mode will be available?

NativeModules.BeaconsAndroidModule returns undefined

Version

1.0.1

Platform

Android

OS version

android 5.1

Steps to reproduce

  1. Create a new React-Native App
  2. Import Beacons from 'react-native-beacons-manager'
  3. In the componentWillMount method of index.android.js file call Beacons.detectIBeacons() function

Expected behavior

App should be able to detect Beacons.

Actual behavior

Getting "Cannot read property 'addParser' of undefined".

v1.0.8 progress (and what can I do to help?)

Version

1.0.8

Platform

iOS

OS version

iOS 10

I've been experiencing difficulty with ranging beacons. Currently this is what happens when i build my app (only testing on iOS atm):

  1. App loads
  2. User grants location permission
  3. Call Beacon listeners
  4. No beacons detected
  5. Have to close and reopen app
  6. Still no beacons detected
  7. Exit beacon radius and finally get an exit event
  8. Beacon monitoring and ranging works fine after this

Bascially, i'm about to launch a project that depends on beacons for the revenue. So two questions:

  1. Are the changes coming in v1.0.8 going to enable ranging of beacons when the app is loaded while in range of one?

  2. What can I do to help get this version out asap? I don't know much about the native side of things, but I can put my full attention on this immediately. Is there a task list anywhere?

Region enter/exit events not firing

Version

1.0.7

Platform

iOS

OS version

iOS 10

Steps to reproduce

  1. Monitor region enter/exiting for a beacon
  2. Toggle beacon activation
  3. Note that no events get fired other than didRange

Expected behavior

regionDidEnter and regionDidExit events should fire when moving in and out of range of a beacon

Actual behavior

regionDidEnter and regionDidExit events do not fire at all

The code I'm using is pulled straight from the README with the exception of adding event listeners for regionDidEnter and regionDidExit:

DeviceEventEmitter.addListener('regionDidEnter', data => {
  console.info('REGION ENTER!', data)
})
DeviceEventEmitter.addListener('regionDidExit', data => {
  console.info('REGION EXIT!', data)
})

and changing my region definition:

const region = {
  identifier: 'Estimotes',
  major: 1,
  minor: 1,
  uuid: '[MY UUID]'
}

No matter what I do, I cannot get either of these events to fire. The only thing I see is that XCode shows the following NSLog output: createBeaconRegion with: identifier - uuid - major - minor

Support for broadcast beacon

Any plans to add support for broadcast beacon? Do you aware of any module which supports broadcast beacon for both iOS and Android? I saw this, but doesn't support android

Additional info.plist key pair required by app store

Platform

iOS

Just got rejected from the app store for not providing a Bluetooth description. this should be added in the docs along with the location services.

We have discovered one or more issues with your recent delivery for β€œYour APP”. To process your delivery, the following issues must be corrected:

Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSBluetoothPeripheralUsageDescription key with a string value explaining to the user how the app uses this data.

Beacons list is always empty while using iOS and Android as Beacons

Version

1.0.2

Platform

iOS | Android

OS version

iOS 10| android 6.0.

Steps to reproduce

I don't have real beacons. I don't have two iOS devices. I have one android device and one iOS device. I tried with the sample code below. The event beaconsDidRange fires but beacons list is empty and the identifier is always Region1 in android and Estimotes in iOS. I tried using the same identifier for android and ios but still beacons list is empty. Events regionDidEnter and regionDidExit never fired.

Expected behavior

Detect android device as a beacon in iOS device.
Detect iOS device as a beacon in android device.

Actual behavior

Beacons list is always empty

if (Platform.OS === 'ios') {
     const region = {
         identifier: 'Estimotes',
         uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
     };
     Beacons.requestAlwaysAuthorization();
     Beacons.startMonitoringForRegion(region);
     Beacons.startRangingBeaconsInRegion(region);
     Beacons.startUpdatingLocation();
   } else {
       Beacons.detectIBeacons();
       try {
         Beacons.startMonitoringForRegion("Region1");
         Beacons.startRangingBeaconsInRegion("Region1");
       } catch (err) {
         console.log(`Beacons ranging not started, error: ${error}`)
       }
   }

   DeviceEventEmitter.addListener('beaconsDidRange', (data) => {
     console.log('Found beacons!', data);
   });
   DeviceEventEmitter.addListener('regionDidEnter', (data) => {
     console.log('regionDidEnter', data);
   });
   DeviceEventEmitter.addListener('regionDidExit', (data) => {
     console.log('regionDidExit', data);
   });

Expo [TypeError: undefined is not an object (evaluating 'BeaconsManager.requestAlwaysAuthorization')]

Hey guys I have problems with expo and react-native-beacons-manager. I used the same code on a blank project and it works without a problem. Just with expo I have this issue.

Version

1.0.1

Platform

iOS | Android

OS version

Version 10.13

iOS 10| android 7.0...

Steps to reproduce

  1. created a new expo project
  2. followed the guideline for react-native-beacons-manager
  3. initialised beacon

CODE:

import React from 'react';
import { StyleSheet, Text, View, DeviceEventEmitter } from 'react-native';

import Beacons from 'react-native-beacons-manager';

export default class App extends React.Component {
state = { beacon: false, proximity: 'wawawa', beaconRange: '', counter: 0};

constructor(props) {
super(props);
// this.socket = SocketIOClient('http://192.168.0.23:3000');
Beacons.requestAlwaysAuthorization();
this.beaconsDidRangeEvent = null;
this.region= {
identifier: 'Estimotes',
uuid: 'CDC19275-FBC7-4E69-A28E-42CD874598123'
}
}
componentWillMount() {
Beacons.requestAlwaysAuthorization();
// Beacons.startRangingBeaconsInRegion(region);
Beacons.startMonitoringForRegion(this.region)
.then(() => console.log('Beacons monitoring started succesfully'))
.catch(error => console.log(Beacons monitoring not started, error: ${error}));
Beacons.startRangingBeaconsInRegion(this.region)
.then(() => console.log('Beacons ranging started succesfully'))
.catch(error => console.log(Beacons ranging not started, error: ${error}));

Beacons.startUpdatingLocation();

}

Expected behavior

Should start beacon request.

Actual behavior

[exp] [TypeError: undefined is not an object (evaluating 'BeaconsManager.requestAlwaysAuthorization')]

Question/ Bug: Beacon is not detected on Android

Version

1.0.7

Platform

Android

OS version

Android 7.0...

Steps to reproduce

Beacons.detectIBeacons()
try {
     Beacons.startRangingBeaconsInRegion(region)
     console.log(`Beacons ranging started successfully!`)
} catch (error) {
     console.log(`Beacons ranging not started, error: ${error}`)
}
  • Both Location and Bluetooth services are on.

Expected behavior

Beacon should be detected.

Actual behavior

Beacon is not detected :/ (it does work on iOS).
Is there anything else I need to do? Do I need to ask for Location permission?

issue in example

var {DeviceEventEmitter} = React;

shouldn't it be React native instead?

Version

1.0.1

Platform

iOS | Android

OS version

iOS 10| android 7.0...

cannot install [urgent]

Version

react-native-beacons-manager 1.0.7

###dev Os: MAcOsX

Target Platforms

iOS | Android

Target OS version

iOS 10| android 6.0...

React info:

react-native version: 0.49.3
react version: 16.0.0-beta.5
react-native-cli: 2.0.1
node version: 7.8.0
npm version: 5.5.1

To install I tried 2 way.

This the passes of the first

  1. sudo npm install --save react-native-beacons-manager

and this the second way:

  1. sudo npm install npm@latest -g
  2. sudo npm install --save react-native-beacons-manager

but in both cases this is the response:
npm WARN [email protected] requires a peer of react@>=15.4.2 but none is installed. You must install peer dependencies yourself.

Expected behavior

install must go fine and use it in react project

Actual behavior

npm WARN [email protected] requires a peer of react@>=15.4.2 but none is installed. You must install peer dependencies yourself.

Have you any solutions?

Thank you for all anyway

Get TxPowerLevel & MAC Address

Hi guys,
I was wondering if we could get the TxPower and MAC address of the beacons once we started ranging for it ?
Because so far I can only get its UUID, minor, major, distance and stuffs.
Thank you very much.

com.facebook.react.bridge errors during gradlew assembleRelease

I'm able to use this library on an android device but when I try to package the APK I get this error. Any ideas?

android> ./gradlew assembleRelease
...
:react-native-beacons-manager:processReleaseJavaRes UP-TO-DATE
:react-native-beacons-manager:compileReleaseJavaWithJavac
/Users/damien/pennpass/node_modules/react-native-beacons-manager/android/src/main/java/com/mackentoch/beaconsandroid/BeaconsAndroidModule.java:10: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.Callback;
.. (more of these same errors about com.facebook.react.bridge)

Warning: Sending event with no listeners registered

Version

1.0.7

Platform

iOS | Android

OS version

iOS 10| android 7.0...

Steps to reproduce

  1. Any usage of the code

Expected behavior

Package should work without warnings

Actual behavior

Warnings are displayed in YellowBox for all events:

  • Sending authorizationStatusDidChange with no listeners registered.
  • Sending didDetermineState with no listeners registered.
  • Sending regionDidEnter with no listeners registered.
  • Sending regionDidExit with no listeners registered.
  • Sending beaconsDidRange with no listeners registered.

regionDidEnter/regionDidExit not firing in background mode

Version

1.0.7

Platform

iOS

OS version

iOS 10

React Native version

0.47.2

Steps to reproduce

  1. use background mode check this documentation
  2. killed/sleeping app, wait 1 minute

Expected behavior

should fire regionDidExit event, and print something

Actual behavior

not fire regionDidExit, but beaconsDidRange is ok when app is foreground, and in background will print nothing.

I build a release package, install it to my device. when get regionDidEnter/regionDidExit/beaconsDidRange event, post data to my test api and save log.
like:

fetch('http://localip:3000/ibeacon', {...fetchOption, body: dataStr})
            .then(() => console.log('iBeacon ok'))
            .catch((error) => console.log('iBeacon error:', error))

monitoring for ios does not seem to work but ranging works fine

Version

1.0.1

Platform

iOS

OS version

iOS 10

Steps to reproduce

  1. copy monitoring.ios.js
  2. run in a example

Expected behavior

Should display enter and exit region information

Actual behavior

It isn't showing anything but ranging works fine if applied there.

ranging beacons events differ from Android to iOS

Version

1.0.1

Platform

iOS | Android

OS version

iOS 10| android 7.0...
android 7 - most likely all Android versions

Steps to reproduce

  1. range for beacons on iOS and Android
  2. iOS returns consistent beacons arrays
  3. Android returns inconsistent beacons array where sometimes the beacon is shown in the array and sometimes it is not.

Expected behavior

Consistent between iOS and Android

Actual behavior

Inconsistente between iOS and Android

Most likely a lower level issue related to the frequency of receiving the messages and confirming that the beacon exists after 3-5 successful fires and same for a beacon not existing. Maybe a nice to have.

I rarely notice this on iOS (testing with three beacons), and all of them fire consistently, where on Android I may see 0, 1, 2, or 3 (rarely) fire.

startMonitoringForRegion without major and minor

Version

1.0.1

Platform

Android

OS version

android 5.0

Steps to reproduce

  1. Call startMonitoringForRegion with only identifier and UUID. Example:
Beacons.startMonitoringForRegion({
    identifier: 'region',
    uuid: 'MY-UU-ID-HELLO-0001111000',
});

Expected behavior

The app should start monitoring

Actual behavior

The app "crashes" with a redbox error and the message: 'TypeError: expected dynamic type 'double' but had type 'null' (constructing arguments for BeaconsANdroidModule.startMonitoring at argument index 2)'

It looks like it doesn't handle well an undefined major/minor in startMonitoringForRegion.

(Note: I'm using react-native-ibeacons but I guess I will have the same problem with this version too?)

beaconsDidRange listener firing more times than expected.

Hello,
I'm implementing a beacon detection where I first use 'beaconsDidRange', with my identifier and uuid, so I can find my beacons. And of those, I get the nearest one. Then I perform an action related to that beacon and monitor the region exit so I can start ranging again and this way keep the detection 'alive'. The first time this code runs everything works as expected. But when I exit the area and the ranging starts again, I get, in the debugger, more than double of the previous listening actions. I don't get why this behaviour happens. I appreciate any help.
(I'm using Android 5.0)

import React, { Component } from 'react';
import {
AppRegistry,
DeviceEventEmitter
} from 'react-native';
import Beacons from 'react-native-beacons-manager';
import moment from 'moment';

const TIME_FORMAT = 'DD/MM/YYYY HH:mm:ss';

export default class BeaconDetection extends Component {
constructor(props) {
	super(props);

	this.state = {
		// region information
		uuid: 'b9407f30-f5f8-466e-aff9-25556b57fe6d',
		identifier: 'WM-IoT',
		major: 0,
		minor: 0,
		foundBeacon: false,
	};
}

componentWillMount() {
	Beacons.detectIBeacons();
}

componentWillUnMount() {
	console.log("UNMOUNT  BEGIN XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
	const { uuid, identifier } = this.state;
	const region = { identifier, uuid };

	// stop ranging beacons:
	Beacons
		.stopRangingBeaconsInRegion(identifier, uuid)
		.then(() => console.log('Beacons ranging stopped succesfully'))
		.catch(error => console.log(`Beacons ranging not stopped, error: ${error}`));

	// stop monitoring beacons:
	Beacons
		.stopMonitoringForRegion(region)
		.then(() => console.log('Beacons monitoring stopped succesfully'))
		.catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`));

	// remove ranging event we registered at componentDidMount
	DeviceEventEmitter.removeListener('beaconsDidRange');
	// remove beacons events we registered at componentDidMount
	DeviceEventEmitter.removeListener('regionDidEnter');
	DeviceEventEmitter.removeListener('regionDidExit');

	console.log("UNMOUNT  END XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

}

render() {
	return (
		this.startDetection()
	);
}

startDetection() {
	const { foundBeacon } = this.state;

	if (foundBeacon) {
		this.startMonitoringBeacon();
	}
	else {
		this.startRanging();
	}

	return null;
}

startMonitoringBeacon() {
	const regionToMonitor = { identifier, uuid, major, minor } = this.state;

	this.doAction(identifier, uuid, minor, major, moment().format(TIME_FORMAT));

	Beacons
		.startMonitoringForRegion(regionToMonitor)
		.then(() => console.log('Beacons monitoring started succesfully'))
		.catch(error => console.log(`Beacons monitoring not started, error: ${error}`));

	DeviceEventEmitter.addListener(
		'regionDidExit',
		({ identifier, uuid, minor, major }) => {
			const time = moment().format(TIME_FORMAT);
			Beacons
				.stopMonitoringForRegion(regionToMonitor)
				.then(() => console.log('Beacons monitoring stopped succesfully'))
				.catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`));
			DeviceEventEmitter.removeListener('regionDidExit');
			console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major, time });
			this.setState({ foundBeacon: false })
		}
	);
}

startRanging() {
	const { identifier, uuid } = this.state;

	// Range beacons inside the region
	Beacons
		.startRangingBeaconsInRegion(identifier, uuid)
		.then(() => console.log('Beacons ranging started succesfully'))
		.catch(error => console.log(`Beacons ranging not started, error: ${error}`));

	// Ranging:
	DeviceEventEmitter.addListener(
		'beaconsDidRange',
		(data) => {
			console.log('beaconsDidRange data: ', data);
			if (data.beacons.length > 0) {
				Beacons
					.stopRangingBeaconsInRegion(identifier, uuid)
					.then(() => console.log('Beacons ranging stopped succesfully'))
					.catch(error => console.log(`Beacons ranging not stopped, error: ${error}`));
				DeviceEventEmitter.removeListener('beaconsDidRange');
				var beacon = this.nearestBeacon(data.beacons);
				console.log("Selected beacon: ", beacon)
				this.setState({ major: beacon.major, minor: beacon.minor, foundBeacon: true })
			}
		}
	);
}

doAction(identifier, uuid, minor, major, time) {
	console.log('AWESOME stuff--------------------------');
	console.log({ identifier, uuid, minor, major, time });
	console.log('AWESOME stuff--------------------------');
}

nearestBeacon(beacons) {
	console.log("beacons", beacons);
	var i;
	var minDistIndex = 0;
	var minDist = Number.MAX_VALUE;
	for (i = 0; i < beacons.length; i++) {
		if (beacons[i].distance < minDist) {
			minDist = beacons[i].distance
			minDistIndex = i;
		}
	}
	return beacons[minDistIndex];
}

}

The debugger:
1st
2

Build fails on iOS with 1.0.5

Version

1.0.5 (version 1.0.4 is not affected)

Platform

iOS

OS version

MacOS

Steps to reproduce

  1. Create a new project using react-native init projectname
  2. Add react-native-beacons-manager and link it.
  3. Add following to index.ios.js
import Beacons from 'react-native-beacons-manager'
  1. Start ios simulator react-native run-ios

Expected behavior

iOS simulator should start without errors

Actual behavior

iOS simulator starts and shows this error:

undefined is not an object  (evaluating 'beaconsAndroid.ARMA_RSSI_FILTER')

module.android.js:23:40

If I remove module.android.js file and all references to it, the build will work.

#28 seems to be related.

Android application crashing on monitoring region when input uuid is null

Version

1.0.7

Platform

Android

Steps to reproduce

  1. start monitoring region with uuid = null

Expected behavior

Should report didEnterRegion, didExitRegion

Actual behavior

Application is crashing

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.altbeacon.beacon.Identi
                            fier.toString()' on a null object reference
                         E      at com.mackentoch.beaconsandroid.BeaconsAndroidModule.createMonitoringResponse(BeaconsAndroidModule.java:2
                            33)
                         E      at com.mackentoch.beaconsandroid.BeaconsAndroidModule.access$100(BeaconsAndroidModule.java:37)
                         E      at com.mackentoch.beaconsandroid.BeaconsAndroidModule$1.didEnterRegion(BeaconsAndroidModule.java:216)
                         E      at org.altbeacon.beacon.BeaconIntentProcessor.onHandleIntent(BeaconIntentProcessor.java:88)
                         E      at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                         E      at android.os.Handler.dispatchMessage(Handler.java:102)
                         E      at android.os.Looper.loop(Looper.java:135)
                         E      at android.os.HandlerThread.run(HandlerThread.java:61)

iOS Beacon signal strength not shown

Version

1.0.1

Platform

iOS

OS version

iOS 10.2.1.

Steps to reproduce

  1. Location and Bluetooth LE enabled from XCode
  2. Code:

const region = {
identifier: 'laa',
uuid: '1596c947-686f-cc35-c9ba-932320a0cce8'
}
Beacons.requestWhenInUseAuthorization();
Beacons.startRangingBeaconsInRegion(region);
Beacons.startUpdatingLocation();

Expected behavior

Get beacon data with signal strength

Actual behavior

Beacons are coming with the data, but rssi is 0 and accuracy -1

Example:

{"beacons":[{"major":1,"minor":0,"uuid":"1596C947-686F-CC35-C9BA-932320A0CCE8","accuracy":-1,"rssi":0,"proximity":"unknown"}

Beacons are iBKS+ beacons and can get signal strength correctly from these beacons using Android with this library.

Scan when app is killed

Version

1.0.1

Platform

Android

OS version

android 6.0.1...

Expected behavior

The app continue detecting beacons even if app is killed

Actual behavior

The scan stops when app is killed

Eddystone beacon support

Eddystone beacon support would make this awesome, but as far as I can see, iBeacon is only supported.

iOS montioring when the app is killed/in background mode does not work

Version

1.0.7

Platform

iOS

OS version

iOS 11.0.2

Steps to reproduce


listener = DeviceEventEmitter.addListener(
        'beaconsDidRange',
        (data) => {

          PushNotification.localNotificationSchedule({
            message: 'Did Detect Beacon', // (required)
            date: new Date(Date.now())
          })
        }
)

Beacons.requestAlwaysAuthorization()
Beacons.startMonitoringForRegion(region)
Beacons.startRangingBeaconsInRegion(region)
Beacons.startUpdatingLocation()

Expected behavior

Beacon should be detected also when the app is killed/in background mode

Actual behavior

The listener callback does not get called (it does get called on foreground)

iOS App rejected due to background permissions

Hey have just used this library for an app and it's worked really great. But I'm now stuck on the app review process, I've had the following back from Apple:

Specifically, because iBeacon entry and exit notifications are provided by the OS to the app, the app itself does not require background location or bluetooth for this feature to function.

It would be appropriate to remove background location and bluetooth from this app’s required background modes section of the Info.plist before resubmitting for review.

Should this work without the background modes?

Adding multiple regions in iOS

Version

1.0.1

Platform

iOS

OS version

iOS 10

Steps to reproduce

  1. Add multiple regions
  2. iOS not supported

Expected behavior

Should add and detect multiple regions.

Actual behavior

Does not work. This maybe related to the todo: startRangingBeaconsInRegion and startMonitoringForRegion should return promises like android

Just testing this out further to confirm, do share if you think of anything.

Conflict with geolocation library that causes app to crash

Version

1.0.4

Platform

iOS

OS version

iOS 10

Steps to reproduce

  1. Create a React Native app that integrates both react-native-beacons-manager and react-native-background-geolocation libraries
  2. Add code to monitor beacons using react-native-beacons-manager
  3. Add code to monitor a geofence around current location using react-native-background-geolocation
  4. Run the app
  5. Exit monitored geofence

Expected behavior

The region exit triggered by react-native-background-geolocation should have no effect on react-native-beacons-manager.

Actual behavior

When react-native-background-geolocation triggers a region exit, it triggers locationManager:didExitRegion in react-native-beacons-manager. Since the region passed to the function is not a beacon region, the proximityUUID selector does not exist, and an error is thrown:

Fatal Exception: NSInvalidArgumentException
-[CLCircularRegion proximityUUID]: unrecognized selector sent to instance 0x170007230

A similar issue is documented with a solution on the react-native-ibeacon package:
frostney/react-native-ibeacon#35

Background mode in IOS

Version

1.0.3 (i tried with 1.0.4 too)

Platform

iOS

OS version

Iphone 5S
iOS 10.2
React native cli: 2.0.1
React native : 0.43.3
React : 16.0.0-alpha.6

Steps to reproduce

I have the Background mode in Xcode project and in Info.plist i add the key : Privacy - Location Always Usage Description

I practically copy paste your examples but when i quit the app, the logging in the console stop instantly and the regionDidEnter/Exit only send uuid and identifier (no information about the beacon itself):

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from "react";
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  AlertIOS,
  DeviceEventEmitter
} from "react-native";
import Beacons from "react-native-beacons-manager";
import BluetoothState from "react-native-bluetooth-state";

export default class testbg extends Component {
  constructor(props) {
    super(props);

    this.state = {
      uuid: "97800498-F50E-4923-9813-65D3875331EC",
      identifier: "demonstration",
    };

    BluetoothState.subscribe(bluetoothState => {
      if (bluetoothState === "off") {
        AlertIOS.alert(
          "Bluethooth warning",
          "Vous devez aciver votre bluetooth"
        );
      }
    });
    BluetoothState.initialize();
  }

  componentWillMount() {
    const { identifier, uuid } = this.state;
    const region = { identifier, uuid };

    DeviceEventEmitter.addListener("authorizationStatusDidChange", info =>
      console.log("authorizationStatusDidChange: ", info));

    Beacons.requestAlwaysAuthorization();
    Beacons.startRangingBeaconsInRegion(region);
    Beacons.startMonitoringForRegion(region);
    Beacons.startUpdatingLocation();
  }

  componentDidMount() {
    DeviceEventEmitter.addListener("beaconsDidRange", data =>
      console.log("ranging - beaconsDidRange data: ", data));

    DeviceEventEmitter.addListener("regionDidEnter", data =>
      console.log("monitoring - regionDidEnter data: ", data));

    DeviceEventEmitter.addListener("regionDidExit", data =>
      console.log("monitoring - regionDidExit data: ", data));
  }

  componentWillUnMount() {
    Beacons.stopMonitoringForRegion();
    Beacons.stopUpdatingLocation();

    DeviceEventEmitter.removeListener("regionDidEnter");
    DeviceEventEmitter.removeListener("regionDidExit");
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{"\n"}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "#F5FCFF"
  },
  welcome: {
    fontSize: 20,
    textAlign: "center",
    margin: 10
  },
  instructions: {
    textAlign: "center",
    color: "#333333",
    marginBottom: 5
  }
});

AppRegistry.registerComponent("testbg", () => testbg);

Expected behavior

Either the ranging works in background or the monitoring send the information about the beacon

Actual behavior

Ranging doesn't trigger when in background and regionDidEnter/Exit only send the region uuid and identifier.
I did some more tests and i have a weird behavior.When i am in background (app closed). the app after a while trigger regionDidEnter/Exit and for a little while trigger beaconsDidRange but beaconsDidRange doesn't actually detect the beacons in range (empty array)

capture d ecran 2017-04-11 a 15 47 26

Sometimes nothing is detected, none of the event are triggered in background.
It's seems pretty random and i don't know what's the cause.

And finally, sometimes i see the beacons when the app is in foreground but if i quit the app nothing is triggered anymore. If i reopen the app, the app trigger the event but doesn't detect any beacons.

capture d ecran 2017-04-11 a 15 58 50

1.0.5 version is not published in npm

Version

1.0.5

Platform

iOS | Android

Steps to reproduce

  1. run yarn add react-native-beacons-manager or npm install react-native-beacons-manager
  2. installed version is 1.0.4

Expected behavior

It should install 1.0.5 version

Actual behavior

install version is 1.0.4

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.