MotionBeacon

iBeacon detection event system. Detect your beacons with ease!

About

The goal of this project is to create a simple and powerful event-based detection system for iBeacons. MotionBeacon is build on top of CLLocationManager, CLBeaconRegion and CLBeacon. Events are inspired by sugarcube-events.

example:

beaconManager.onEnterRegion { |region| my_code }

Installation

gem install motion-beacon

# in Rakefile require 'motion-beacon'

# in terminal $ bundle install

Usage

# create beacon manager
bm = BeaconManager.new('XXXXX-YYY-ZZZ-AAAA-BBBBBBBBB', 'com.company.iBeacons')

# initialize regions
bm.createRegion(major: 0, minor: 1)

# activate region detection
bm.startRangingBeacons(major: 0, minor: 1)

# entering region events
bm.onEnterRegion { |region| my_code }
bm.onEnterRegion(major: 1) { |region| my_code }

# leaving region events
bm.onLeaveRegion { |region| my_code }
bm.onLeaveRegion(major: 1, minor: 1) { |region| my_code }

# changing regions event
bm.onChangeRegion { |oldRegion, newRegion| my_code }

# loosing all regions event
bm.onLostRegions { my_code }

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request