iBeaconManager 0.1.0

iBeaconManager 0.1.0

Duncan MacDonald 维护。



  • oct0f1sh

iBeaconManager

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install

需求

使用 iBeaconManager,您必须导入 iBeaconManager 和 CoreLocation。

import CoreLocation
import iBeaconManager

您还必须在您的 Info.plist 中添加对 NSLocationAlwaysAndWhenInUseUsageDescriptionNSLocationWhenInUseUsageDescription 的描述。

安装

iBeaconManager 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中即可

pod 'iBeaconManager'

用法

// 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")
    }
}

作者

oct0f1sh, [email protected]

许可证

iBeaconManager 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。