iOS Ibeacon: How to Get All of Proximityuuid Programmatically

iOS iBeacon: How to get all of proximityUUID programmatically?

Unfortunately, you cannot to this on iOS. When you say that BLExplr and LightBlue can do this, you are confusing the Bluetooth service UUID with the iBeacon Proximity UUID. These are two very different things.

The Bluetooth service UUID is visible to iOS, but has nothing to do with an iBeacon's identifiers, and is useless for working with iBeacons. The service UUID is generated by iOS each time a bluetooth device is seen, and stays the same only for the duration of time the bluetooth device is in range. If you take a bluetooth device away and bring it back later, it will have a different service UUID.

An iBeacon's identifiers (ProximityUUID, Major, Minor) are embedded inside the body of the Bluetooth advertisement. The problem on iOS devices is that Apple's CoreBluetooth APIs disallow access to the raw advertisement body, so no third-party app is able to read these identifiers. Apple only allows access to these identifiers using the special iBeacon CoreLocation APIs, but these APIs require you to know the Proximity UUID up front.

Sorry, I know this is not the answer you want to hear! (I'm sorry about it, too!) For what it's worth, you can do this on Android, on OSX Mavericks and Linux.

See details here.

Get iBeacon proximity updates using CLLocationManager

The beacon.proximity field will be updated with each callback to func locationManager(_: CLLocationManager, didRangeBeacons: [CLBeacon], in: CLBeaconRegion). These callbacks will come once per second with an array of CLBeacon objects that have this field. So every 1 second you will get an update.

Based on the way the code is set up, it appears that beaconsInProximity will be updated properly if the beacon is in immediate proximity and switchLamp will be called later in the callback method.

Understand, however, that the CLBeacon's proximity field may not update as quickly as you'd like. This field is derived from the accuracy field, which is a distance estimate in meters. If the distance estimate is < 0.5 meters, then accuracy will be set to immediate. If the distance estimate is > 0.5 meters, it will be set to another value.

The distance estimate in accuracy is based on a 20 second running average of the RSSI measurements. Because of this, if you very quickly move from 5 meters away to right next to the beacon transmitter, the accuracy field will slowly change from ~5.0 to ~0.0 over the course of 20 seconds. It will take nearly 20 seconds for the proximity field to show immediate.

Also, it is important to understand that the beacon must be calibrated properly with the measuredPower value set inside the beacon for as accurate distance estimates as possible. If you are getting very inaccurate distance estimates in accuracy even after staying still for 20 seconds, then you may need to do this calibration.

Get unique identifier for beacon in iOS?

Solved. For my case (Jaalee beacons) I should perform a lot of actions in the following order:

  1. scan for beacons
  2. store beacon I found into a dictionary and request its service list
  3. if I get service list then I request characteristic list
  4. if I get characteristic list then I request value for
    characteristics I need
  5. If all the previous steps are successful then I get beacon
    proximityUUID, major and minor which are all in common represent
    "unique identifier"

All these steps are called asynchronously. Additionally I should delete from dictionary of beacons I found on disconnecting from them. I should also check on some steps if a beacon is still connected.

UUID which is "too unique" I use for a key in a dictionary because the beacon objects are called asynchronously.

iBeacon unique identifier with private api

It is possible to detect any iBeacon regardless of identifiers if you use private APIs. The basic idea is to create a subclass of CLBeaconRegion but make an internal structure that mirrors the standard iOS implementation. This implementation currently lets you specify that you want to see any beacon regardless of UUID.

Sample code can be found in this project.

Two caveats here:

  1. Because this uses a private API, Apple will certainly not approve apps with this code for distribution by the AppStore.

  2. This relies on an internal implementation of CLBeaconRegion that could change with any future release of iOS and stop working.



Related Topics



Leave a reply



Submit