Reputation: 393
I am trying to scan near beacons and get info from them. Now i get some like uuid, major-minor values but i want t read advertisement data too. There is my code how can i handle it ?
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
}
}
}
}
Upvotes: 1
Views: 2078
Reputation: 64941
Unfortunately, you cannot access raw advertisement data for iBeacon advertisements in iOS. Apple actively blocks access to the bluetooth advertisement data for any Bluetooth advertisement packet matching the iBeacon format.
This means the ProximityUUID, major and minor are all you can read.
See here for more details.
Upvotes: 2