Beacon library for adHawk implementations on Android
Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
demo
lib
.gitignore
LICENSE
README.md
build.gradle
settings.gradle

README.md

beacon-android-sdk

Android library for integration with the RevelDigital platform for beacons

This purpose of this library is to efficiently monitor and relay beacon information to apps wishing to integrate with the RevelDigital platform. Beacon information is delivered via broadcast to any listening BroadcastReceiver registered to an application. Once the libary has been initialized the app will begin receiving various broadcasts when in the vicinity of beacons registered on the RevelDigital platform. The beacon broadcasts will include not only the beacon device information, but also references to the media and any other scheduled content assigned to a specific beacon. All communication with the RevelDigital platform is handled by the library including device monitoring, analytics, user profile syncronization, and content scheduling.

Dependencies

  • gson-2.6.2 compile 'com.google.code.gson:gson:2.6.2'
  • okio-1.6.0 compile 'com.squareup.okio:okio:1.6.0'
  • okhttp-urlconnection-2.7.0 compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.0'
  • okhttp-2.7.0 compile 'com.squareup.okhttp:okhttp:2.7.0'
  • retrofit-1.9.0 compile 'com.squareup.retrofit:retrofit:1.9.0'
  • support-v4-22.1.1 compile 'com.android.support:support-v4:22.1.1'
  • joda-time-2.8.2 compile 'joda-time:joda-time:2.8.2'
  • play-services-base-8.4.0 compile 'com.google.android.gms:play-services-base:8.4.0'
  • play-services-maps-8.4.0 compile 'com.google.android.gms:play-services-maps:8.4.0'
  • play-services-location-8.4.0 compile 'com.google.android.gms:play-services-location:8.4.0'
  • reveldigital-api-1.4.6 compile 'com.reveldigital:reveldigital-api:1.4.6'
  • playerapi-1.0-SNAPSHOT request access by emailing support@reveldigital.com

Download

Android libraries are available in the lib folder, or via Maven:

Download the latest snapshot or grab via Maven:

<dependency>
  <groupId>com.reveldigital.adhawk</groupId>
  <artifactId>beacon-android-sdk</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

or Gradle:

compile 'com.reveldigital.adhawk:beacon-android-sdk:1.0-SNAPSHOT'

Usage

To start

try {
  BeaconClient beaconClient = new BeaconClient.Builder(this).startOnBoot(true).build();
  beaconClient.connect();
} catch (BeaconClient.MalformedRevelBeaconException e) {
  e.printStackTrace();
}

To stop

beaconClient.disconnect();

How to receive beacon data

Register a BroadcastReceiver either manually or via an intent-filter in your AndroidManifest.xml

An example of manual broadcast registration:

IntentFilter intentFound = new IntentFilter(ACTION_BEACON_FOUND);
registerReceiver(myReceiver, intentFound);

An example of intent-filter in AndroidManifest.xml:

<intent-filter>
  <action android:name="com.reveldigital.adhawk.lib.action.BEACON_FOUND"/>
</intent-filter>
<intent-filter>
  <action android:name="com.reveldigital.adhawk.lib.action.BEACON_EXPIRED"/>
</intent-filter>

Extract the beacon data from the broadcast intent:

if (intent.getAction().equals(ACTION_BEACON_FOUND)) {
  Bundle extras = intent.getExtras();
  Bundle b = extras.getBundle(EXTRA_BEACON_BUNDLE);
  b.setClassLoader(Beacon.class.getClassLoader()); // for cross process applications
  Beacon beacon = b.getParcelable(EXTRA_BEACON);
}

The two actions containing beacon data include

  • ACTION_BEACON_EXPIRED
  • ACTION_BEACON_FOUND

Authorization

An authorization key is required in order to communicate with the RevelDigital API. This key is generated by RevelDigital and provided to app developers on a request basis.

The auth key must be included in your AndroidManifest.xml resource file using the meta-data tag.

 <meta-data
  android:name="com.reveldigital.adhawk.API_KEY"
  android:value="YOUR_KEY_HERE"/>

To request your key please email info@reveldigital.com with your company and contact details.

Documentation

Please refer to the Javadoc found here: http://developer.reveldigital.com/gen/beaconsdk