Skip to content

drlube/iBeaconsPlugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Cordova iBeacons Plugin

This plugin enables iBeacon discovery for your Cordova (Phonegap) application.

Supported Platforms

Only devices that support Bluetooth 4 (Bluetooth LE, Bluetooth Smart) are supported.

  • iOS 7+
  • Android 4.3+ (Work in progress...)

General TODO:

  • Better handling of local notifications.
  • Handle modals in the cordova app.

Android TODO:

Download Radius Networks Android iBeacon Library:

That was copied into src/android/libs/AndroidIBeaconLibrary

  • Need to figure out src/android/libs/AndroidIBeaconLibrary/build.xml and what it's all about

  • Need to figure out src/android/libs/AndroidIBeaconLibrary/local.properties and what it's all about

  • Need to figure out src/android/libs/AndroidIBeaconLibrary/project.properties merging. Need to add a couple lines:

    android.library.reference.2=libs/AndroidIBeaconLibrary manifestmerger.enabled=true

Installing

Install with Cordova cli

$ cordova plugin add https://github.com/Attendease/iBeaconsPlugin.git

Examples

There are no examples... yet!

API

Methods

monitor

Monitor beacon UUIDs

AttendeaseBeacons.connect(UUIDs, callback);

getBeacons

After you monitor the beacons you can start getting beacons that are found.

AttendeaseBeacons.getBeacons(callback);

The callback returns an array of beacons it has found.

notifyServer

When the app is in the background we can't talk to the Phonegap javascript so we send a beacon POST to the specified server.

AttendeaseBeacons.notifyServer(theServerToPostTo, interval);

The theServerToPostTo to post to is... the server to post to! The interval is so we don't flood the server with beacons. If we find a beacon we wait that many seconds to send the same beacon again.

notifyServerAuthToken

Our server needs credentials to link the beacon to an attendee. This is here for that reason.

AttendeaseBeacons.notifyServerAuthToken(theAuthToken);

Amazing Example

var uuidsToMonitor;

AttendeaseBeacons.notifyServer(theServerToPostTo, 900); // 900 seconds

AttendeaseBeacons.notifyServerAuthToken(theAuthToken);

uuidsToMonitor = ["E2C56DB5-DFFB-48D2-B060-D0F5A71096E0", "B9407F30-F5F8-466E-AFF9-25556B57FE6D"];

AttendeaseBeacons.monitor(uuidsToMonitor, function() {
  return setInterval((function() {
    return AttendeaseBeacons.getBeacons(function(beacons) {
      if (_.isEmpty(beacons)) {
        return console.log("No beacons found.");
      } else {
        return _.each(beacons, function(beacon) {
          return console.log("" + beacon.uuid + " (" + beacon.major + ", " + beacon.minor + ") " + beacon.proximityString + " (" + beacon.accuracy + " meters)");
        });
      }
    });
  }), 3000);
});

Feedback

Give the code a try. If you find any issues or missing features please let us know or create a pull request.

About

Cordova iBeacons Plugin for iOS and Android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published