简体   繁体   中英

How to get iBeacon CLBeaconRegion identifier (not uuid)?

It's pretty frustrating to not being able to retrieve identifier from 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?

The identifier is associated with the region, you can simply access region.identifier

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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