iOS Tutorial iBeacons

iBeacons are small, low powered peripherals, that use BLE (Bluetooth Low Energy) to advertise their information.

The BeaconParser class can be used together with the BLE library to search for beacons. On Android, BeaconParser will find iBeacons, however not on iOS. iOS treats iBeacons in a different way.

The attached example extends the Location library with inline Objective C code to search for iBeacons.

You need to know the iBeacon UDID of the beacon you are searching for.
The user will need to first allow the app to access the location services (don't miss the two #PlistExtra lines).

The DidRangeBeacons event will be raised when a beacon is discovered:
Sub LocManager_DidRangeBeacons (Beacons As List)
   For Each Beacon As NativeObject In Beacons
     Dim UUID As String = Beacon.GetField("proximityUUID").AsString
     Dim Major As Int = Beacon.GetField("major").AsNumber
     Dim Minor As Int = Beacon.GetField("minor").AsNumber
     Dim proximity As Int = Beacon.GetField("proximity").AsNumber '0 = unknown, 1 = immediate, 2 = near, 3 = far
     Dim rssi As Int = Beacon.GetField("rssi").AsNumber
     TextView1.Text = $"Beacon found: ${UUID}
Major: ${Major}
Minor: ${Minor}
Proximity: ${proximity}
RSSI: ${rssi}
Time: $Time{DateTime.Now}
End Sub


Note that you can use another iOS device to emulate an iBeacon. For example:


    3.1 KB · Views: 591