如何获取 iBeacon CLBeaconRegion 标识符(不是 uuid)?

How to get iBeacon CLBeaconRegion identifier (not uuid)?

无法从 CLBeaconRegion 检索标识符真是令人沮丧。这是一个简化的例子:

let beaconRegion = CLBeaconRegion(uuid: UUID(uuidString: "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0")!, major: 111, minor: 222, identifier: "NewBeacon")

locationManager?.startMonitoring(for: beaconRegion)
locationManager?.startRangingBeacons(in: beaconRegion)

func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
    if let beacon = beacons.first {
        print(beacon.identifier) //that
    }
}

有没有办法获得 "NewBeacon" 标识符?

标识符与区域关联,您可以直接访问region.identifier