如何获取 BLE 广告数据 Swift 2

How to get BLE Advertisement Data Swift 2

我正在尝试扫描附近的信标并从中获取信息。现在我得到一些像 uuid,主要次要值,但我也不想读取广告数据。有我的代码,我该如何处理?

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

遗憾的是,您无法访问 iOS 中 iBeacon 广告的原始广告数据。 Apple 主动阻止任何匹配 iBeacon 格式的蓝牙广告数据包访问蓝牙广告数据。

这意味着 ProximityUUID,major 和 minor 都是你可以阅读的。

有关详细信息,请参阅 here