IOS7 adds support for iBeacon. Internet is full of headlines:
- Why iBeacon may be the most important feature of iOS7
.
- iBeacon will open a new era of location applications
.
- How iBeacon can kill NFC
.
- iBeacon and the future of mobile payments
.
According to journalists, this is a super technology that will change the market for mobile payments, indoor navigation, consumer habits and at the same time kill NFC.
Under the cut, I'll tell you what iBeacon really is, how you can use it and show an example of an application for navigating
our office.
')
iBeacon is a beacon that transmits three parameters of proximity UUID, major and minor via
Bluetooth Low Energy . iOS7 makes it easy to work with such devices.
proximity UUID is a unique 128-bit identifier, all the beacons of your company or within a building have the same pUUID.
major and
minor are 16-bit unsigned integers for the numbering of beacons within one pUUID. These are Apple recommendations, you can set absolutely any values ​​for these parameters, but the recommended scheme is more convenient.
Available pre-order on the beacons from
Estimote and
Kontakt .
One beacon costs $ 30, works two years from the battery. Many companies are
refining their products to support the iBeacon profile. I think within three months there will be Chinese counterparts at $ 10.
iOS devices can act as a beacon, it allows you to play with the new API now.
Three classes have been added to the
Core Location Framework : CLBeacon, CLBeaconRegion and CLCircularRegion. In CLLocationManager, the methods areRangingAvailable, rangedRegions, requestStateForRegion, startMonitoringForRegion, startRangingBeaconsInRegion, and the corresponding events in CLLocationManagerDelegate appeared. startMonitoringForRegion now supports not only GPS regions but also Bluetooth. About how to use it is described
in detail
in the documentation .
In fact, the new API provides two possibilities:
- Obtaining a list of beacons in sight with a specific Proximity UUID (you can narrow down the search by specifying the value major or major / minor) using the startRangingBeaconsInRegion method. The API determines the distance to the beacon (Immediate, Near, Far) and the distance error in meters.
- Monitoring the region. When a user enters or leaves the beacon, the didEnterRegion / didEnterRegion events occur (startMonitoringForRegion method). Moreover, monitoring works even when your application is in the background, when an event occurs, the application will be awakened.
Use the data to obtain the coordinates of the device in the room
can not . In the explanation of the error of the distance (accuracy) it is directly written “to make a beacon”. Experiments confirm the data is not suitable for triangulation.
Possible applications of iBeacons:
- Indoor navigation: we hang the beacons in each room (the same proximity UUID, different major for floors / departments, different minor for rooms). On the map we display the nearest beacon to the smartphone.
- Interactive tour of the museum: for each exhibit sticking beacons, when approaching the exhibit we show additional information about it.
- Accurate positioning in the city. We hang beacons on monuments and objects of architecture. The whole city turns into a museum.
- Navigation for the blind. When a beacon is detected, play a voice message where the user is and where to go next.
- Location games and quests. For example, a simple demo game " find a monkey "
- Discounts and promotions in stores. We pass by the jeans (a beacon is installed on the rack) and we receive a message about a buy-two-pair-third-in-gift.
- Tincture equipment. Not sure if this is generally related to iBeacon, but with iOS7 Apple TV can be customized with the touch of an iPhone .
iPhone 4s +, iPad 3+ can work as a beacon. I decided to write a simple navigation through our office using test iOS devices. If you do not have Xamarin.iOS or a desire to build an application, try the
Estimote App . The app demonstrates new features (two iOS devices with Bluetooth LE are required).
So. Our office map:
For navigation, you need beacons with iOS7, I dialed test devices and laid them out in the center of cabinets 310, 311 and 312. It took a total of 3 beacons and one receiver.

We take the Xamarin
AirLocate demo application as a
basis . It is able to turn on the proximity UUID, major and minor translation (parameters are configured) and display a list of available beacons around with given pUUID.
Application code with navigation through our office is available
on github . Just want to apologize for the terrible code, I am a marketer and this is my first iOS application.
Set beacons the same proximity UUID, major set equal to the number of the cabinet. Beacon activation code (does not work in the background, you need to turn off auto-lock):
CLBeaconRegion region = new CLBeaconRegion (uuid, major.UInt16Value, minor.UInt16Value, Defaults.Identifier); if (region != null) peripheralManager.StartAdvertising (region.GetPeripheralData (power));
AirLocate gives a list of available beacons with distance and accuracy, an example of 312 cabinets (the beacon of 310 does not finish off).
Create a
MapViewController that will draw a rectangle above the cabinet, the number of which is contained in the major nearest beacon.
locationManager = new CLLocationManager (); locationManager.DidRangeBeacons += HandleDidRangeBeacons; locationManager.StartRangingBeacons (new CLBeaconRegion(Defaults.SupportedProximityUuids[0], "office_beacon"));
void HandleDidRangeBeacons (object sender, CLRegionBeaconsRangedEventArgs e) { drawRegion (e.Beacons [0]); }
switch ((int)(beacon.Major)) { case 310: path.AddRect(roomCoords[0]); break; case 311: path.AddRect(roomCoords[1]); break; case 312: path.AddRect(roomCoords[2]); break; }
(sorry again for the terrible code).
Now you can walk around the office and test.

Works!
The accuracy of the definition of the cabinet is excellent, but the update rate is not very, if you go to another room with the usual step, the map will be updated in 10-30 seconds.
The app is worth improving. Add threshold accuracy, so that in neighboring offices and a corridor without beacons, the map does not draw cabinets with beacons. And to draw not rectangles, but circles with accuracy radius. But for demonstration purposes it is enough.
In general, nothing revolutionary iBeacon from itself is not, but Apple definitely gave a strong impetus to the development of radar applications. For iOS7, they are written in a dozen lines of code.
The picture in the cap from the site estimote.com, images of lighthouses from the sites of manufacturers.
Subscribe to our
blog . Every Thursday useful articles about mobile development, marketing and business of mobile studio.