測試 iBeacons
首先,你必須請求授權位置服務
let locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
// OR locationManager.requestAlwaysAuthorization()
然後你可以在 didRangeBeacons
裡面獲取所有 iBeacons 的資訊
func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
for beacon in beacons {
print(beacon.major)
print(beacon.minor)
}
}