Search for "ibeacon" in the Conducttr template library
Code for the Android app is on GitHub
Table of Contents
This document describes how to create a personalized location-based experience using Bluetooth beacons and Android smartphones.
The audience receives custom content based on their proximity to the beacons, personalizing their experience to their movement and behavior.
The code snippet we provide must be embedded in an Android mobile app where it will detect Bluetooth beacons and send API calls to your project in Conducttr.
First the audience needs to install the mobile app. When the app first opens it will display a signup form to enter a name and phone number. From then on the app displays how near or far the beacons are.
As the audience moves, the app listens for the beacons and as it gets closer or further away the app sends triggers to Conducttr revealing the proximity and direction of the audience and triggering events the author has defined.
BLE – Bluetooth low energy is a wireless network technology.
Bluetooth Beacon – A device capable of sending BLE signals.
Proximity Zones - There are three static zones that surround each beacon. The distances are approximate and can vary widely:
- Immediate Zone (0-20 cm)
- Near Zone (20 cm - 2 m)
- Far Zone (2 - 70 m)
Each recipe has the following sections:
- Ingredients what you need to complete this project
- Preparation how to prepare
- Method step-by-step guide
Note: you’ll need to install the Android development environment to build the app but once that’s in place the rest is straightforward.
You will need:
- Eclipse to edit the code app.
- Eclipse & Android SDK bundle: http://developer.android.com/sdk/index.html
- Eclipse: http://www.eclipse.org/downloads/
- The app code snippet.
- A set of Bluetooth beacons (or emulator app – usually downloadable for free to a mobile device)
- An Android smartphone with BLE capabilities and Android 4.3 or superior
- A Conducttr project
Before following the Method section, please do the following:
- Create a Conducttr project
- Create new API entry inside Conducttr (call it App)
Now you have all the ingredients and you’ve followed the preparation, you’re now ready to configure the project. The steps are:
- Create API triggers in Conducttr that will fire when the app calls them
- Update the app code snippet with details from your project
- Import the OAuth library
- Import the Android IBeacon Library
- Check log to see that the app is calling Conducttr as expected.
Create an API trigger for each beacon event (going form a zone to another) – like the one shown below
Note: Matchphrases sent by the app to the Conducttr project are in the format - such as: from-near-to-far, from-immediate-to-near and so on.
Imort the iBeaconWithConducttr project into your workspace in Eclipse.
File -> Import -> Android -> Existing Code into Workspace
Then open src->com.conducttr.ibeaconwithconducttr-> Constants.java
The area that you have to edit is between two comment lines. The start of the editable area says “Edit the information below” – as shown in the image.
You need to update the following information:
- CONDUCTTR CONSUMER KEY & CONSUMER SECRET – you’ll find this in the Authentication section of the API pop-up
- CONDUCTTR PROJECT ID – this is found in the top header bar
- COUNT – Number of times you want the app to sample the scans of beacons before calling Conducttr. Note: the readings of bluetooth beacons fluctuate, so getting more samples means slower detection but a higher accuracy
126.96.36.199 Import the OAuth library
Copy the JAR files signpost-commonshttp4-188.8.131.52 & signpost-core-184.108.40.206 into the \libs folder of your project iBeaconWithConducttr
220.127.116.11 Import the Android IBeacon Library
Import the AndroidIBeaconLibrary project into your workspace in Eclipse
File -> Import -> Android -> Existing Projects into Workspace
Update file Project.properties of iBeaconWithConducttr project to link the library