iBeaconManager 0.1.0

iBeaconManager 0.1.0

Maintained by Duncan MacDonald.



  • By
  • oct0f1sh

iBeaconManager

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

To use iBeaconManager you must import both iBeaconManager and CoreLocation.

import CoreLocation
import iBeaconManager

You also must add a description for NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription in your Info.plist.

Installation

iBeaconManager is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'iBeaconManager'

Usage

// subclass BeaconManagerDelegate
class ExampleClass: BeaconManagerDelegate {
    var beaconManager: BeaconManager
    
    init() {
        // create a Beacon object
        let beacon = Beacon(uuid: "00000000-0000-0000-0000-000000000000", major: 1234, minor: 5678, identifier: "example beacon")
        
        // initialize the BeaconManager class by passing in your Beacon object
        beaconManager = BeaconManager(beacon: beacon)
        
        // start monitoring for beacon activity
        beaconManager.startMonitoring()
    }
    
    // add protocol methods
    func beaconManager(sender: BeaconManager, isInBeaconRange region: CLRegion) {
        print("inside beacon range")
    }
    
    func beaconManager(sender: BeaconManager, isNotInBeaconRange region: CLRegion) {
        print("not inside beacon range")
    }
    
    func beaconManager(sender: BeaconManager, searchingInRegion region: CLRegion) {
        print("searching for beacon")
    }
    
    func beaconManager(sender: BeaconManager, enteredBeaconRegion region: CLRegion) {
        print("entered beacon region")
    }
    
    func beaconManager(sender: BeaconManager, exitedBeaconRegion region: CLRegion) {
        print("exited beacon region")
    }
    
    func beaconManager(sender: BeaconManager, monitoringRegionFailed region: CLRegion, withError error: Error) {
        print("monitoring for beacon failed")
    }
}

Author

oct0f1sh, [email protected]

License

iBeaconManager is available under the MIT license. See the LICENSE file for more info.