Welcome to the Proximi.io Cordova plugin reference. Use our library to hook into the new Proximi.io platform.
Code samples can be found on the right side of the page.
Cordova plugin installation is really easy. Issue the following command in your Cordova project:
cordova plugin add https://github.com/proximiio/proximiio-cordova.git
In case you're using Ionic, the installation is similar:
ionic plugin add https://github.com/proximiio/proximiio-cordova.git
proximiio object is globally accessible variable exposed by Cordova. It's usually good idea to put proximiio initialization inside deviceReady or platformReady callbacks
var PROXIMIIO_TOKEN = 'PUT_YOUR_APPLCIATION_TOKEN_HERE';
function initProximiio() {
proximiio.setDebugOutput(true, null, null);
proximiio.setProximiioReadyCallback(function (visitorId) {
document.getElementById('visitor').innerHTML = visitorId;
proximiio.requestPermissions();
});
proximiio.setOutputTriggerCallback(function (output) {
// Your code here
});
proximiio.setInputTriggerCallback(function(enter, geofence) {
// Your code here
});
proximiio.setPositionChangeCallback(function(coords) {
// Your code here, for example:
//document.getElementById("position-latitude").innerHTML = coords.coordinates.lat;
//document.getElementById("position-longitude").innerHTML = coords.coordinates.lon;
//document.getElementById("position-accuracy").innerHTML = coords.accuracy;
});
// call this method after hooking up your callbacks
proximiio.setToken(PROXIMIIO_TOKEN);
},
Happy coding! Not what you needed? Check out the rest below.
First thing to do before adding any callbacks is to authenticate with the Proximi.io Proximity Platform. You can find the required token from the Proximi.io Web Portal Manage Applications section.
proximiio.setToken(PROXIMIIO_TOKEN);
Cordova plugin offers multiple callbacks which are triggered by different events.
proximiioReadyCallback is triggered when Proximio.io SDK is fully initialized;
proximiio.setProximiioReadyCallback(function(visitorId) {
document.getElementById("visitor_id").innerHTML = visitorId;
})
geofenceTriggerCallback is triggered when someone enters or exits a defined geofence.
proximiio.setGeofenceTriggerCallback(function(enter, geofence) {
document.getElementById("address").innerHTML = geofence.address
document.getElementById("lat").innerHTML = geofence.area.lat
document.getElementById("long").innerHTML = geofence.area.lng
document.getElementById("createdAt").innerHTML = geofence.createdAt
document.getElementById("department_id").innerHTML = geofence.department_id
document.getElementById("id").innerHTML = geofence.id
document.getElementById("name").innerHTML = geofence.name
document.getElementById("organization_id").innerHTML = geofence.organization_id
document.getElementById("place_id").innerHTML = geofence.place_id
document.getElementById("radius").innerHTML = geofence.radius
document.getElementById("updatedAt").innerHTML = geofence.updatedAt
});
outputTriggerCallback is triggered when output payload is available. Output payload is defined in the web portal action flow editor using function node and event transmitter.
proximiio.setOutputTriggerCallback(function (output) {
// Your code here
//
// Contains the JSON object as it was defined in the
// action flow editor before passing it to the event transmitter as a payload
});
positionChangeCallback is triggered when Proximi.io SDK detects a major change in the users position.
proximiio.setPositionChangeCallback(function(coords) {
// Your code here, for example:
document.getElementById("position-latitude").innerHTML = coords.coordinates.lat;
document.getElementById("position-longitude").innerHTML = coords.coordinates.lon;
document.getElementById("position-accuracy").innerHTML = coords.accuracy;
});
floorChangedCallback is triggered when Proximi.io SDK detects a floor change.
proximiio.setFloorChangedCallback(function(floor) {
// Your code here, for example:
document.getElementById("floor-anchors").innerHTML = JSON.stringify(floor.anchors, null, 4)
document.getElementById("floor-createdAt").innerHTML = floor.createdAt;
document.getElementById("floor-id").innerHTML = floor.id;
document.getElementById("floor-name").innerHTML = floor.name;
document.getElementById("floor-organization_id").innerHTML = floor.organization_id;
document.getElementById("floor-.place_id").innerHTML = floor.place_id;
document.getElementById("floor-updatedAt").innerHTML = floor.updatedAt;
});
beaconFoundCallback is triggered when Proximio.io SDK detects a beacon;
proximiio.setBeaconFoundCallback(function(beacon) {
document.getElementById("beacon-uuid").innerHTML = beacon.uuid;
document.getElementById("beacon-major").innerHTML = beacon.major;
document.getElementById("beacon-minor").innerHTML = beacon.minor;
})
beaconLostCallback is triggered when Proximio.io SDK looses beacon from sight;
proximiio.setBeaconLostCallback(function(beacon) {
document.getElementById("beacon-uuid").innerHTML = beacon.uuid;
document.getElementById("beacon-major").innerHTML = beacon.major;
document.getElementById("beacon-minor").innerHTML = beacon.minor;
})
floorChangedCallback is triggered when Proximio.io SDK detects a floor change;
proximiio.setFloorChangedCallback(function(floor) {
document.getElementById("floor").innerHTML = floor;
})
sets Proximi.io SDK to handle output Push messages automatically
proximiio.handlePush(true);
uses internal proximi.io method for requesting permissions (location & bluetooth)
// Example TBA