简体   繁体   English

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

[英]How to get iBeacon CLBeaconRegion identifier (not uuid)?

It's pretty frustrating to not being able to retrieve identifier from CLBeaconRegion.无法从 CLBeaconRegion 检索标识符非常令人沮丧。 Here's a simplified example:这是一个简化的示例:

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
    }
}

Is there a way to get "NewBeacon" identifier?有没有办法获得“NewBeacon”标识符?

The identifier is associated with the region, you can simply access region.identifier标识符与区域相关联,您可以简单地访问region.identifier

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM