Cordova – checkedOutOfBeaconCallback

/*
 *  Provide a callback for a Beacon with a Custom Action being checked out of.  The is iBeacon 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 4: Date of check-in (Integer - UNIX timestamp)
 *      Parameter 5: Dwell time in minutes (Unsigned integer)
 *      Parameter 6: JSON Object of custom data (JSON Object)
 */
exports.checkedOutOfBeaconCallback = function( callback )
{
    exec( callback, null, "BDPointSDK", "checkedOutOfBeaconCallback", [] );
}

Description

This function provides a callback function to the SDK that will be called when the device is no longer 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 co-ordinate of the Beacon placement
    • Parameter 2: Zone Info array
      • Zone name
      • Zone description
      • Zone id
    • Parameter 3: Proximity of the Beacon at point of check-in
    • Parameter 4: Date of check-in; this is provided as a UNIX timestamp
    • Parameter 5: Dwell time in minutes
    • Parameter 6: JSON Object of custom data

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 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 Beacon with a Custom action that has been checked out of by the SDK.
 *  Refer to bluedotPointSDKCDVPlugin.js for more information.
 */
function beaconCheckOut( beaconInfo, zoneInfo, proximity, date, dwellTime, 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;
     
    updateStatus( ( ( isiBeacon == true ) ? "iBeacon " : "" ) + beaconName + " has been left in " + zoneName + " after " + dwellTime + " minutes" );
    updateStatus( JSON.stringify(customData) );
}
Created by Bluedot DevOps on January 16, 2018

Start the discussion