The BeaconRegionManager is a lightweight library for managing iBeacon regions in iOS apps. It provides a simple and straightforward interface for monitoring and ranging iBeacons.
Installation
To install BeaconRegionManager, follow these steps:
- Add the following line to your Podfile:
pod 'BeaconRegionManager', '~> 1.0'
- Run
pod install
command.
Usage
To begin using BeaconRegionManager in your project, follow these steps:
- Import the BeaconRegionManager module into your file:
import BeaconRegionManager
- Create an instance of the BeaconRegionManager:
let regionManager = BeaconRegionManager()
- Set the delegate of the region manager to receive events:
regionManager.delegate = self
- Add the desired iBeacon regions:
regionManager.addRegion(uuid: "YOUR_BEACON_UUID", identifier: "YOUR_BEACON_IDENTIFIER")
- Implement the BeaconRegionManagerDelegate protocol in your class:
class YourClass: BeaconRegionManagerDelegate { // Implement delegate methods here }
- Start monitoring and/or ranging the iBeacon regions:
regionManager.startMonitoringRegions()
regionManager.startRangingRegions()
- Implement the delegate methods to handle beacon events:
func didEnterRegion(region: CLBeaconRegion) { // Handle region entry event } func didExitRegion(region: CLBeaconRegion) { // Handle region exit event } func didRangeBeacons(beacons: [CLBeacon], region: CLBeaconRegion) { // Handle beacon ranging event }
Requirements
BeaconRegionManager has the following requirements:
- iOS 10.0+
- Xcode 12+
- Swift 5.0+
License
BeaconRegionManager is available under the MIT license. See the LICENSE file for more information.