Follow

iBeacons - triggering by proximity

Search for "ibeacon" in the Conducttr template library
Code for the Android app is on GitHub 

 

Table of Contents

1  Scope

1.1  What does it do?

1.2  How does it work?

1.3  Definitions

2  The Recipe

2.1  Ingredients

2.2  Preparation

2.3  Method

2.3.1  Create the triggers

2.3.2  Update the app code

 

1  Scope

This document describes how to create a personalized location-based experience using Bluetooth beacons and Android smartphones.

 

1.1  What does it do?

The audience receives custom content based on their proximity to the beacons, personalizing their experience to their movement and behavior.

 

1.2  How does it work?

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.

1.1  Definitions

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)

 

2  The Recipe

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.

 

2.1  Ingredients

You will need:

  1. Eclipse to edit the code app.
    1. Eclipse & Android SDK bundle: http://developer.android.com/sdk/index.html
    2. Eclipse: http://www.eclipse.org/downloads/
  2. The app code snippet.
  3. A set of Bluetooth beacons (or emulator app – usually downloadable for free to a mobile device)
  4. An Android smartphone with BLE capabilities and Android 4.3 or superior
  5. A Conducttr project

 

2.2  Preparation

Before following the Method section, please do the following:

  1. Create a Conducttr project
  2. Create new API entry inside Conducttr (call it App)

 

2.3  Method

Now you have all the ingredients and you’ve followed the preparation, you’re now ready to configure the project. The steps are:

  1. Create API triggers in Conducttr that will fire when the app calls them
  2. Update the app code snippet with details from your project
    1. Import the OAuth library
    2. Import the Android IBeacon Library
  3. Check log to see that the app is calling Conducttr as expected.

 

2.3.1  Create the triggers

Create an API trigger for each beacon event (going form a zone to another) – like the one shown below

Matchphrase       UUID-MAJOR-MINOR-from-PreviousZone-to-ActualZone

 

EG: 73676723-7400-0000-ffff-0000ffff0002-0-1048-from-NEAR-to-FAR

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.

 

 

2.3.2  Update the app code

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

 

 

2.3.2.1  Import the OAuth library 

Copy the JAR files signpost-commonshttp4-1.2.1.2 & signpost-core-1.2.1.2 into the \libs folder of your project iBeaconWithConducttr

 

2.3.2.2  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

                      

target=android-18
manifestmerger.enabled=true
android.library.reference.1=../AndroidIBeaconLibrary

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments