Playing with iBeacons: Supporting Them in Your Native Mobile App
What is iBeacon? iBeacon technology is Apple’s version of Internet of Things solution. It allows Bluetooth devices to broadcast or receive small and static bits of data within small distances. These small pieces of data can trigger actions on an iOS device that helps app developers to add real-world experiences for the users. For example, each beacon can transmit information from which the app can detect how close or far it is from the beacons and then perform actions, display alerts to the users, provide offers and discounts for the patrons, an d so on.
Supporting iBeacons in Native Mobile Apps iBeacons do the work of a GPS in a small area where we cannot be assured of GPS being accurate. It can enable an interaction between an iOS or Android mobile app and an area such as a room, park, shop, caf ĂŠ, etc. With the help of AltBeacon library, which is a specification that defines the format of the broadcasted messages from the Bluetooth Low Energy proximity beacons, we can add iBeacons to our Android or iOS devices and display them within an application. We start our process by adding the AltBeacon library in our build process. This will allow us to use the library in our project.
After including the AltBeacon library, certain application permissions need to be set for it. Since iBeacons are nothing bu t Bluetooth devices, we must first enable the several Bluetooth permissions. Also, these iBeacons work off proximity, so there must be several location services that need to be enabled. The beacons for the application will be placed in a list. So, we requi re a layout for our activity to include ListView components. After the ListView component is added, we will scan for iBeacons and populate the list that we just created in the UI. We setup a parser that will look for Bluetooth packets matching the ListView. The next step is to define a listener for beacons that fall into the range and defines which beacons we need to listen. We define a single region with only a region ID which facilitates all beacons that match the iBeacon specification to be listened for. In a single notification, we can receive any number of iBeacons. We will iterate over each beacon returned and add them into the list. Within an application, users need to grant permission to use various device features otherwise some functionalities asso ciated with the iBeacons may not work. In real-time scenarios, we would not need to scan for all the iBeacon that exists. We would only require a specific set of iBeacons based on say, a remote database. Based on the ID of the region, we can scan and liste n to the specific iBeacons. The list of iBeacons, instead of refreshing after every call simply adds in the list. The application at this point runs successfully interacting with the iBeacons in local proximity. AltBeacon library is rich with features. Using the AltBeacon library in the native application we scanned iBeacons and set up regions. If we consider a use-case of iBeacons in a shop, we will see that iBeacons placed in strategic locations can inform, guide or give special information, offers to cus tomers through a mobile notification while on the move.