Skip to content

shodanuk/react-native-estimote

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please note the docs below are for the original fork of this repository which can be found at https://github.com/jacobrosenthal/react-native-estimote

Whilst this fork provides similar functionality, it focuses on the Beacons section of the Estimote SDK API as opposed to the Nearables functionality that the original repo focussed on. I've also wrapped a couple more bits of functionality for iOS and attempted and also added basic Android functionality.

It's unlikely that I'll do any further work on this module now so feel free to fork or PR, if you find it useful.


react-native-estimote

React Native extensions for the Estimote iOS SDK

INSTALL

The depenency story on react native is still very incomplete so bear with me. From your existing react native project:

npm i --save react-native-estimote

Next see the react native linking guide for visual instructions, but you need to open your project and from node_modules/react-native-estimote drag RNEstimote.xcodeproj into your project file browser. Next navigate to your top level project and for your main target, click Build Phases and drag the libRNEstimote.a product into the Link Binary With Libraries section.

Then click the + button at the bottom to add CoreBluetooth, CoreLocation and SystemConfiguration Frameworks.

Lastly copy the EstimoteSDK/EstimoteSDK.framework from the Estimote iOS SDK (3.2.7 or greater) into your project root. Then drag it from there into your project as you did with RNEstimote.xcodeproj (though you dont need to Link Binary this time)

Background monitoring requires the "Uses Bluetooth LE accessories" Capability to be set. Background ranging is complicated

USE

The Estimote SDK is required reading. This library attempts to usilize its conventions as closely as possible. Where nearable or nearable arrays are returned theyre converted to dictionaries or arrays of dictionaries, with most enums converted to strings.

Require the library and grab the react emitter:

var Estimote = require('react-native-estimote');
var DeviceEventEmitter = React.DeviceEventEmitter;

Utilize one of the Estimote APIs. All the constants are exported on the object like Estimote.ESTNearableTypeAll. Note, the Estimote nearable Identifier is seperate from the UUID.

Estimote.startMonitoringForIdentifier("4ba718229b92a8b3");

Then maybe in your react definition add listeners and handlers:

  componentWillMount: function(){
	var didEnterIdentifierRegion = DeviceEventEmitter.addListener(
	  'didEnterIdentifierRegion', this.didEnterIdentifierRegion
	);
	var didExitIdentifierRegion = DeviceEventEmitter.addListener(
	  'didExitIdentifierRegion', this.didExitIdentifierRegion
	);
  },
  didEnterIdentifierRegion: function(data){
    console.log("didEnterIdentifierRegion", JSON.stringify(data));
  },
  didExitIdentifierRegion: function(data){
    console.log("didExitIdentifierRegion", JSON.stringify(data));
  },

Which will print

	didEnterIdentifierRegion {"identifier":"4ba718239b91a8b3"} main.jsbundle:10:9550
	didExitIdentifierRegion {"identifier":"4ba718239b91a8b3"} main.jsbundle:10:9550

BACKGROUNDING

If you add the uses bluetooth le accessories capability your delegates will be called while your app is in the background, but not when killed or on the lock screen. It turns out that Estimote doesnt use ibeacon apis under the hood and is thus ineligible for that :( To get that behavior you may utilize react-native-ibeacon in tandem to startMonitoringForRegion of the uuid (as opposed top the nearable id)

About

React Native extensions for the Estimote iOS SDK

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 61.5%
  • Java 37.4%
  • JavaScript 1.1%