我正在尝试扫描附近的信标并从中获取信息。现在我得到一些像uuid,major-minor值,但我也想读广告数据。我的代码如何处理?
func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion)
{
// Tells the delegate that one or more beacons are in range.
let foundBeacons = beacons
if foundBeacons.count > 0 {
if let closestBeacon = foundBeacons[0] as? CLBeacon {
var proximityMessage: String!
let makeString = "Beacon Details:\n"
let uuid = "UUID = \(closestBeacon.proximityUUID.UUIDString)\n"
let identifier = "Identifier = \(region.identifier)\n"
let major = "Major Value = \(closestBeacon.major.intValue)\n"
let minor = "Minor Value = \(closestBeacon.minor.intValue)\n"
let distance = "Distance From iBeacon = \(proximityMessage)"
self.beaconStatus.text = makeString
self.uuidStatus.text=uuid
self.distanceStatus.text=distance
}
}
}
}
答案 0 :(得分:2)
不幸的是,您无法访问iOS中的iBeacon广告的原始广告数据。对于与iBeacon格式匹配的任何蓝牙广告包,Apple主动阻止访问蓝牙广告数据。
这意味着您可以阅读ProximityUUID,major和minor。
有关详细信息,请参阅here。