Logical Labs Beacons Module for Android

API Docs for: 1.2.5
Show:

Readme

The Logical Labs Beacons module allows Titanium apps to communicate with beacons.

Usage

To access this module from JavaScript, you would do the following:

var Beacons = require("com.logicallabs.beacons");

The Beacons variable is a reference to the Module object.

The next step is to wait for the moduleReady event.

Use the createBeaconRegion function to create beacon region objects:

 var beaconRegion = Beacons.createBeaconRegion({
                            UUID: uuid,
                            identifier: '#' + idCounter
                    });

This object then can be passed to the startRegionMonitoring function to start monitoring:

Beacons.startRegionMonitoring({
    beaconRegion: region
});

This will result in enteredRegion, exitedRegion, and regionStateUpdated events.

Once the user enters a region, the startRangingBeacons function can be used to get periodic updates about the beacons in range:

Beacons.addEventListener('regionStateUpdated', function(e) {
    switch(e.state) {
        case Beacons.REGION_STATE_INSIDE:
            Beacons.startRangingBeacons({
                beaconRegion: e.region
            });
            break;
        case Beacons.REGION_STATE_OUTSIDE:
            Beacons.stopRangingBeacons({
                beaconRegion: e.region
            });
            break;
    }
});

This will result in rangedBeacons events.

Use the stopRangingBeacons and stopRegionMonitoring functions to stop ranging and monitoring, respectively.

Background operation

Your app will receive beacon related events normally as long as it is in memory, even if it is in the background.

Use the setAppLaunchIntent function to configure the module to automatically launch your app when a beacon is detected after the Android device was rebooted.

Issues and Limitations

Change Log

Version 1.2.0

  • Initial release

Version 1.2.1

  • Documentation and sample app improvements.

Version 1.2.5

Author

Zsombor Papp, Logical Labs

titanium@logicallabs.com

License

Logical Labs Commercial License

Copyright (c) 2012-2014 by Logical Labs, LLC