Cordova – checkedIntoBeaconCallback

/*
 *  Provide a callback for a Beacon with a Custom Action being checked into. The isiBeacon boolean is used to determine
 *  if the proximityUUID/major/minor should be utilised or the MAC Address.
 *
 *  Returns the following multipart status:
 *      Parameter 1: Array identifying Beacon:
 *          name (String)
 *          description (String)
 *          ID (String)
 *          isiBeacon (BOOL)
 *          proximity UUID (String)
 *          major (Integer)
 *          minor (Integer)
 *          MAC address (String)
 *          latitude (Double)
 *          longitude (Double)
 *      Parameter 2: Array of strings identifying zone containing Beacon:
 *          name (String)
 *          description (String)
 *          ID (String)
 *      Parameter 3: Proximity of check-in to Beacon (Integer)
 *          0 = Unknown
 *          1 = Immediate
 *          2 = Near
 *          3 = Far
 *      Parameter 3: Array of double values identifying location:
 *          Date of check-in (Integer - UNIX timestamp)
 *          Latitude of Beacon setting (Double)
 *          Longitude of Beacon setting (Double)
 *          Bearing of Beacon setting (Double)
 *          Speed of Beacon setting (Double)
 *      Parameter 4: Proximity of check-in to Beacon (Integer)
 *          0 = Unknown
 *          1 = Immediate
 *          2 = Near
 *          3 = Far
 *      Parameter 5: Beacon is awaiting check-out (Boolean)
 *      Parameter 6: JSON Object of custom data (JSON Object)
 */
exports.checkedIntoBeaconCallback = function( callback )
{
    exec( callback, null, "BDPointSDK", "checkedIntoBeaconCallback", [] );
}

Description

This function provides a callback function to the SDK that will be called when the device has triggered an action by being in the proximity of a Beacon.  Identifying information on the Beacon, the zone, and the proximity at which the Beacon caused a trigger, are passed back to the callback function.

Parameters

callback (Function)

This is a function that will be called when the device has been triggered a Beacon at a configured proximity.

Function parameters

The callback function has passed 6 parameters of Beacon information, including the zone the Beacon is within; each entry contains the following information in the order provided:

    • Parameter 1: Beacon Info array
      • Beacon name
      • Beacon description
      • Beacon id
      • Is an iBeacon – is set to true if the Beacon is an iBeacon
      • Proximity UUID of iBeacon
      • Major value of iBeacon
      • Minor value of iBeacon
      • MAC Address
      • Latitudinal coordinate of the Beacon placement
    • Parameter 2: Zone Info array
      • Zone name
      • Zone description
      • Zone id
    • Parameter 3: Location Info array
      • Date of check-in; this is provided as a UNIX timestamp
      • Latitudinal coordinate at the point of Beacon
      • Longitudinal coordinate at the point of Beacon
      • Bearing degree at the point of Beacon
      • Speed at the point of Beacon
    • Parameter 4: Proximity of the Beacon at point of check-in
    • Parameter 5: Beacon is awaiting check-out
    • Parameter 6: JSON Object of custom data (JSON Object)

These strings can be accessed by using an enum as demonstrated in the bdFunctions.js Javascript wrapper that is bundled with the Bluedot plug-in.

const zoneInfoEnum =
{
    name: 0,
    description: 1,
    ID: 2
}
const beaconInfoEnum =
{
    name: 0,
    description: 1,
    ID: 2,
    isiBeacon: 3,
    proximityUUID: 4,
    major: 5,
    minor: 6,
    MACAddress: 7,
    lat: 8,
    lon: 9
}
const locationInfoEnum =
{
    timestamp: 0,
    latitude: 1,
    longitude: 2,
    bearing: 3,
    speed: 4
}
const proximityEnum =
{
    Unknown : 0,
    Immediate : 1,
    Near : 2,
    Far : 3,
    properties:
    {
        0: { name: "Unknown", value: 0, code: "U" },
        1: { name: "Immediate", value: 1, code: "I" },
        2: { name: "Near", value: 2, code: "N" },
        3: { name: "Far", value: 3, code: "F" }
    }
}
 
/*
 *  This delegate function receives the data of a fence with a Custom action that has been triggered by the SDK.
 *  Refer to bluedotPointSDKCDVPlugin.js for more information.
 */
function beaconTrigger( beaconInfo, zoneInfo, locationInfo, proximity, willCheckOut, customData )
{
    //  Extract details for a status update
    var beaconName = beaconInfo[ beaconInfoEnum.name ];
    var isiBeacon = beaconInfo[ beaconInfoEnum.isiBeacon ];
    var zoneName = zoneInfo[ zoneInfoEnum.name ];
    var proximityName = proximityEnum.properties[ proximity ].name;
    var lat = locationInfo [ locationInfoEnum.latitude ];
    var lon = locationInfo [ locationInfoEnum.longitude ];
 
    updateStatus( ( ( isiBeacon == true ) ? "iBeacon " : "" ) + beaconName + " has been triggered in " + zoneName + " with a proximity of " + proximityName + " at " + lat + ":" + lon  );
    updateStatus( JSON.stringify(customData) );
 
    if ( willCheckOut == true )
    {
        updateStatus( "Beacon is awaiting check-out" )
    }
}
Created by Bluedot DevOps on January 16, 2018

Start the discussion