Intive Blog

iBeacons

The iBeacon is a technology developed by Apple in 2013. Said beacon consists of a low powered Blue Tooth device which broadcasts a signal according to the protocol designed by Apple. The purpose of this gadget is to be detected by mobile devices and be used a means to determine the local position of the user in relation to the beacon. That’s it,, nothing more or nothing less. At first glance, it seems like a very basic function. However, with a bit of imagination, can have many applications. Let’s take a look at the actual device:

2

1

As you can see, the device is very small. It’s worth noting that while the concept and the protocol belong to Apple, the device can be built by different vendors. Therefore, it comes in many shapes and sizes. The function, however, remains the same across all models. Also, unlike other Apple inventions, the device can be used by Android and Windows phone devices.

 

Implementation:

First of all, let’s take a look the the signals broadcasted by the beacon:

3When you purchase one of these devices, the documentation should say what values that beacon is broadcasting. If not, you can use public apps to detect these values (like “iBeacon Detector” and “Particle Detector”). The signal is meant to be used in a hierarchical order. Being the UUID the most important one. The reason why the other two values exist is because you can have several beacons with the same UUID with different areas or subareas. We’ll better illustrate this in the example at the end. Now, let’s get into some code.

The code for the detection of this signal is fairly simple and straight forward. First off, we must create a CLLocationManager and request the proper authorization:

4

Keep in mind that in order for the authorization request to work, you must also write the authorization request text in the project .plist:

5

After that, we create a Beacon Region and tell the Location Manager to start monitoring for it:

6

And that’s it! Now, when the device enters a region, it’ll begin to look for the signal broadcasted with that particular UUID (so long the device’s blue tooth service is active, of course). It should also be mentioned that we can tell the app to look for more than one beacon region. Just create more CLBeaconRegion objects and use the “startMonitoringForRegion:” method to listen for them, as well, this way you can have beacons with different UUIDs. Now, let’s take a quick look at the delegate methods for the detection events related to this:

7

 

Murder mystery time!

In order to better understand how to use this feature, let’s look a hypothetical example:

8

Let’s pretend that you’re making an Alternative Reality Game (ARG), one which takes place in an actual physical mansion. The players would play the role of a team of detectives who are piecing the clues of a murder perpetrated that evening. The function of the app would be to feed the players pieces of the story and contextual information when they get in a particular room and complete a certain action. And that’s not all, they are also high-tech detectives. The app will give them special “detectors” to tell them when they are close to a clue. Using the camera (with Augmented Reality), the players will scan this special spot to reveal the clue that will lead them to another room and unlock the next part of the story.

This sounds cool on paper, doesn’t it? But…, can be implemented? Of course, the answer is yes. In order to trigger these events, we must track the position of the user at all times with a relative level of precision. Here is how the floor plan of the mansion would look like:

9

By using several beacons with different information, we can tell in which room the user will located and feed him data accordingly. Here is how it would look according to the signals given by the beacons:

10Let’s break this down:

  • The area within the blue outline would represent ALL of the beacons. This determines whether or not the user is within the mansion to begin with. To achieve this, all the beacons will have the same “UUID”.
  • The areas within the other colored outlines would be represented by a particular “Mayor” value for that place.
  • Finally, the areas with the red circled X would represent the special spots where the “Clue Detector” would tell the user that a clue is near by. These areas can be determined by the “Minor” value.

In short, with this technology, we have the basis to make a game that uses actual physical space to engage the user.

 

Conclusion

iBeacon technology has as many applications as we could imagine. Whether it be something as complex as video game or just a clothing store app, the principles remain the same. So, have fun coding with it.

Ezequiel González

Ezequiel Gonzalez is IOS developer at intive since August 2011. Videogame developer graduated from Escuela de Arte Multimedial Da Vinci, he worked two years as a QA tester and one year as a prototype developer for Flash games. Ezequiel´s hobbies are drawing, reading and playing videogames. He also goes to yoga once a week and excercices at home.

Add comment