BEACONS


TABLE OF CONTENTS


 MONITOR BEACONS

 ANDROID

In order to start the monitoring services to look for beacon campaigns, you need to update the demographics stored in memory. Otherwise, you won’t be able to start those services and your SDK will return an IllgealStateException.

You employ the following method:


    D2GO.updateDemographics(JSONArray demographics, Context context)

The demographics JSONArray that’s being passed in as a parameter is structured in the following format:

The following two methods run the services to monitor beacon campaigns:

But you need to run D2GOSDK.init(…) (described in Installation section) and D2GOSDK.updateDemographics(…) first to avoid getting the following excpetions:

If you later wish to stop the monitoring services, you can call the following two methods:

 IOS

Monitoring Digital2GO beacons requires a Beacon UUID and a Beacon Region Identifier, both of which are provided by the Digital2GO platform upon the creation of a new app.

To begin monitoring a beacon region, define the region. You define a beacon region with the appropriate initialization of the CLBeaconRegion class. An example is shown below, illustrating how the two keys (UUID and region identifier) are used to create the region to monitor.

Then, you call the startRangingBeacons method, which starts the delivery of notifications for the specified beacon region.

When a new beacon is detected, you will get notified through the didRangeBeacons as part of the CLLocationManagerDelegate protocol.

 SENDING BEACON IMPRESSIONS TO THE SERVER

To send a beacon impression to the Digital2GO server, you use the following API:

https://api.digital2go.com/impressions/beacon.json

You need to pass a JSON object into the API the following format:

If there is an active campaign that matches this impression, the campaign content will be returned as a JSON Object in the following format:

Other possible responses include:

  • 401 Incorrect Login
  • 404 No Campaign Found
  • 422 Beacon Input Validation Failed
  • 500 An unknown condition error means that something has gone wrong with the data on the system. This could be expected when data doesn't exist on the system (i.e. trying to create a zone when a location doesn't exist).

 ANDROID

To catch and handle beacon impressions, you need to create a new broadcast receiver and copy the following settings into your AndroidManifest.xml.

You can catch the campaigns in your broadcast receiver as shown below. The campaign content is a string in the format shown previously.


 IOS

To acquire beacon content, you use the d2gAPIRequest.postJSON method.

The method below illustrates how you'd call the API to send a beacon impression to the server. The sTargetURL variable represents the API URL and the data variable is the data in the format shown previously.


For additional questions or technical support, please contact developers@digital2go.com.