Monitor POIs with Geofence

How to track user’s Visits and identify his Zone of interest with Cordova plugin.

  1. Collect user’s Visits
  2. Zone of Interest (ZOI)

Get the location and the time spent when a user is visiting places. These use cases are explained in the Visit and ZOI documentation.

Collect user’s Visits

Enable visits and ZOI monitoring

It is recommended to use the visitsTracking profile to monitor visits and identify ZOI.

JavaScript
        cordova.plugins.WoosmapGeofencing.startTracking('visitsTracking', onSuccess, onError);

    

Remove visits

Call deleteVisit method to remove all Visits from the local db.

JavaScript
        cordova.plugins.WoosmapDb.deleteVisit(success, error);

    

Get visits from the local database

Call getVisits method to get an array of Visits from the local db.

JavaScript
        const success = function (result) {
        showSuccessToast("Total Visits: " + result.length);
    };
cordova.plugins.WoosmapDb.getVisits(success, error);

    

Watch visit to track visit’s events

Call watchVisits method to track Visits. Method will invoke a callback with Visit object. Method will return a watch id which can be used later to remove the callback.

JavaScript
        const visitCallback = function (visit) {
	console.log("Visit:" + visit);
};

const error = function (err) {
	console.log(err);
};

var visitWatchId = cordova.plugins.WoosmapGeofencing.watchVisits(visitCallback, error);

    

To remove watch:

JavaScript
        cordova.plugins.WoosmapGeofencing.clearVisitsWatch(visitWatchId, success, error);

    

Zone of Interest (ZOI)

Remove ZOI

Call deleteZoi method to remove all Visits from the local db.

JavaScript
        cordova.plugins.WoosmapDb.deleteZoi(success,error);

    

Get ZOI from the local database

Call getZois method to get an array of Visits from the local db.

JavaScript
        const success = function (result) {
        showSuccessToast("Total ZOIs: " + result.length);
    };
cordova.plugins.WoosmapDb.getZois(success, error);

    
Was this article helpful?
Have more questions? Submit a request