Skip to content

iBeacon advertising and scanning in a Titanium module

License

Notifications You must be signed in to change notification settings

marcoschierhorn/TiBeacons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

See this example app for usage: TiBeacons Example App

Become an iBeacon:

var TiBeacons = require('org.beuckman.tibeacons');

TiBeacons.addEventListener("advertisingStatus", function(event) {
    Ti.API.info(event.status);
});

TiBeacons.startAdvertisingBeacon({
   uuid : "00000000-0000-0000-0000-000000000000",
   identifier : "TiBeacon Test",
   major: 1,
   minor: 2
});

Start monitoring for iBeacons in one or more regions:

TiBeacons.startMonitoringForRegion({
    uuid : "00000000-0000-0000-0000-000000000000",
    identifier : "Test Region 1",
});

TiBeacons.startRangingForBeacons({
    uuid : "00000000-0000-0000-0000-000000000001",
    identifier : "Test Region 2 (group-specific)",
    major: 1
});

TiBeacons.startRangingForBeacons({
    uuid : "00000000-0000-0000-0000-000000000002",
    identifier : "Test Region 3 (device-specific)",
    major: 1,
    minor: 2
});

Listen for region events:

TiBeacons.addEventListener("enteredRegion", alert);
TiBeacons.addEventListener("exitedRegion", alert);
TiBeacons.addEventListener("determinedRegionState", alert);

If auto-ranging is enabled, the module will automatically start ranging when a region is entered.

TiBeacons.enableAutoRanging();

Listen for the range events:

TiBeacons.addEventListener("beaconRanges", function(event) {
   alert(event.beacons);
});

Or just listen for beacon proximity changes:

TiBeacons.addEventListener("beaconProximity", function(e){
   alert("beacon "+e.major+"/"+e.minor+" is now "+e.proximity);
});

About

iBeacon advertising and scanning in a Titanium module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 90.6%
  • Python 7.4%
  • JavaScript 1.7%
  • C 0.3%