All Projects → MacKentoch → React Native Ibeacons

MacKentoch / React Native Ibeacons

Licence: mit
React Native library for detecting beacons (iOS and Android)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to React Native Ibeacons

Luch
Small and easy to use Android library for BLE beacon monitoring
Stars: ✭ 55 (+511.11%)
Mutual labels:  beacon, ibeacon
react-native-ibeacon-simulator
Simulate device act as an iBeacon, or transmit as an iBeacon signal from your phone
Stars: ✭ 48 (+433.33%)
Mutual labels:  ibeacon, beacon
React Native Beacons Manager
React-Native library for detecting beacons (iOS and Android)
Stars: ✭ 467 (+5088.89%)
Mutual labels:  beacon, ibeacon
ios
CoThings's iOS application. CoThings is a realtime counter for shared things.
Stars: ✭ 13 (+44.44%)
Mutual labels:  ibeacon, beacon
win-beacon
Managed BT stack for Windows able to detect and act as an iBeacon.
Stars: ✭ 49 (+444.44%)
Mutual labels:  ibeacon, beacon
React Native Kontaktio
React Native (iOS and Android) library for Kontakt.io beacons (and all other beacons)
Stars: ✭ 87 (+866.67%)
Mutual labels:  beacon, ibeacon
Android Sdk
Beaconstac ADVANCED SDK for Android devices
Stars: ✭ 18 (+100%)
Mutual labels:  beacon, ibeacon
Reactivebeacons
Android library scanning BLE beacons nearby with RxJava
Stars: ✭ 171 (+1800%)
Mutual labels:  beacon, ibeacon
PiBeacon
Low-cost iBeacon using Raspberry Pi
Stars: ✭ 41 (+355.56%)
Mutual labels:  ibeacon, beacon
iBeacon-Android
iBeacon scanner and simulator - Android application example
Stars: ✭ 28 (+211.11%)
Mutual labels:  ibeacon, beacon
CobaltStrike Script Wechat Push
CobatStrike-Script, Beacon上线,微信实时推送!
Stars: ✭ 41 (+355.56%)
Mutual labels:  beacon
IoT-iBeacon
An Ionic app for indoor localization and navigation using BLE iBeacons.
Stars: ✭ 39 (+333.33%)
Mutual labels:  ibeacon
Geacon
Practice Go programming and implement CobaltStrike's Beacon in Go
Stars: ✭ 460 (+5011.11%)
Mutual labels:  beacon
BLE-Beacon-Tracking-System
Indoor Beacon Tracking System based on BLE
Stars: ✭ 18 (+100%)
Mutual labels:  beacon
tapit-app
App which lets two people share their social media details by simply putting one phone on top of the other ("tapping"). Currently in development by Nikita Mounier.
Stars: ✭ 18 (+100%)
Mutual labels:  ibeacon
SDK-iOS
DEMO for Sensoro SDK
Stars: ✭ 35 (+288.89%)
Mutual labels:  ibeacon
Ping Blocker
Stop sites from tracking the links you visit through hyperlink auditing
Stars: ✭ 23 (+155.56%)
Mutual labels:  beacon
Awesome Beacon
A curated list of awesome Bluetooth beacon software and tools.
Stars: ✭ 785 (+8622.22%)
Mutual labels:  ibeacon
Black Hat Rust
Applied offensive security with Rust - Early access - https://academy.kerkour.com/black-hat-rust?coupon=GITHUB
Stars: ✭ 331 (+3577.78%)
Mutual labels:  beacon
Android Beacon Scanner
A simple android iBeacon, AltBeacon, Eddystone and RuuviTag beacon scanner
Stars: ✭ 277 (+2977.78%)
Mutual labels:  ibeacon

npm

react-native-ibeacons

IMPORTANT this repository is deprecated and has moved to react-native-beacons-manager

logo

react-native-ibeacons: 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 2 original awesome:

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

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-ibeacons

or via yarn:

yarn install react-native-ibeacons

2. link to your application

react-native link react-native-ibeacons

3.a configuration specific to iOS

IMPORTANT: you have to set Bluetooth and localization service in background Modes

ios: active background mode

3.b configuration specific to Android

Nothing (lucky Android 😄).

4 usage

4.a iOS

Simple example

var React = require('react-native');
var {DeviceEventEmitter} = React;

var Beacons = require('react-native-ibeacons');

// Define a region which can be identifier + uuid,
// identifier + uuid + major or identifier + uuid + major + minor
// (minor and major properties are numbers)
var 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
var 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.
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.
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
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.
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-ibeacons'

// 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
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).
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.

license

The MIT License (MIT)

Copyright (c) 2017 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].
OSZAR »