Coder Social home page Coder Social logo

kiritm-nimblechapps / react-native-kontaktio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from driversnote-dev/react-native-kontaktio

0.0 3.0 0.0 4.6 MB

React Native (iOS and Android) library for Kontakt.io beacons (and all other beacons)

License: MIT License

JavaScript 19.52% Python 0.68% Java 20.53% Objective-C 57.95% Ruby 0.26% Shell 1.05%

react-native-kontaktio's Introduction

react-native-kontaktio npm version

Cross-platform React Native module for detecting beacons with Android and iOS devices.

Kontakt.io SDK Versions:

OS SDK Version
Android 3.3.0
iOS 1.4.3

Advantages

  • Works with any beacon (because the Kontakt.io SDK wraps the native beacon libraries (while adding more) - no Kontakt.io SDK API key is necessary.
  • Especially useful with Kontakt.io beacons because additional information like the unique id (on the back of each beacon), the battery power level and others are available and get synchronized with your Kontakt.io online panel.
  • Highly customizable configurations (e.g. for setting arbitrary monitoring intervals on Android)

Setup

API Documentation

Examples

Extensive Example

Minimal Example

A minimal example with the default configuration and no specifically set regions. Thus, the default region everywhere (i.e. all beacons) is automatically used.

Android

Example/src/MinimalExample.android.js:

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

import Kontakt from 'react-native-kontaktio';
const { connect, startScanning } = Kontakt;

export default class MinimalExample extends Component {
  componentDidMount() {
    connect()
      .then(() => startScanning())
      .catch(error => console.log('error', error));

    DeviceEventEmitter.addListener(
      'beaconsDidUpdate',
      ({ beacons, region }) => {
        console.log('beaconsDidUpdate', beacons, region);
      }
    );
  }

  render() {
    return <View />;
  }
}

iOS

Example/src/MinimalExample.ios.js:

import React, { Component } from 'react';
import { View, NativeEventEmitter } from 'react-native';

import Kontakt, { KontaktModule } from 'react-native-kontaktio';
const { init, startScanning } = Kontakt;

const kontaktEmitter = new NativeEventEmitter(KontaktModule);

/**
 * Minimal example of react-native-kontaktio
 */
export default class MinimalExample extends Component {
  componentDidMount() {
    init()
      .then(() => startDiscovery())
      .catch(error => alert('error', error));

    // Add beacon listener
    kontaktEmitter.addListener(
      'didDiscoverDevices',
      ({ beacons }) => {
        console.log('didDiscoverDevices', beacons);
      }
    );
  }

  render() {
    return <View />;
  }
}

Run Example to test the module

  1. Clone this repository, connect an Android and/or Apple device to your computer and have some (Kontakt.io) beacons handy

  2. Open a terminal window, bash to the Example/ folder, run npm install and start the react-native server

    $ cd react-native-kontaktio/Example
    $ npm install
    $ npm start
  3. Build the example and run it on your device. The app will appear under the name KontaktIoSimpleTest:

    • Android:

       $ react-native run-android
    • iOS

       $ react-native run-ios

Further notes

  • Beacons support is part of Android versions 4.3 and up.
    • So far the lowest Android version this library was tested on was a device with Android 4.4.2.
  • A physical device must be used for testing, at best some Kontakt.io beacons.

ToDo:

  • Update Android Eddystone feature:

    • Add multiple Eddystone namespaces, i.e. add function setEddystoneNamespaces
    • Add Eddystone Frames Selection configuration option
  • iOS: Eddystone support

react-native-kontaktio's People

Contributors

andrekovac avatar exkazuu avatar jdpigeon avatar

Watchers

 avatar  avatar  avatar

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.