Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
cordova-plugin-service-worker-geofencing
Advanced tools
Geofencing plugin for Cordova Service Worker
The cordova geofencing plugin enables developers to set up set up region monitoring and handle boundary crossing events with a service worker. Regions persist even when the app is quit and are monitored even when your app is in the background. Check out this spec for a full reference of the Service Worker Geofencing API.
To add the plugin to your project, use this cli command from within your project
cordova plugin add https://github.com/MobileChromeApps/cordova-plugin-service-worker-geofencing.git
or, to install from npm:
cordova plugin add cordova-plugin-service-worker-geofencing
To remove the plugin use
cordova plugin rm cordova-plugin-service-worker-geofencing
Note: For this plugin to work properly, you must first install the cordova service worker plugin before installing the geofencing plugin.
On your active page:
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
var region = new CircularGeofenceRegion("Name", latitude, longitude, radius);
serviceWorkerRegistration.geofencing.add(region).then(function(regionRegistration) {
console.log("Created Geofence " + regionRegistration);
}, function(error) {
console.log("Error: " + error);
});
});
In your service worker script:
self.ongeofenceenter = function(event) {
console.log("Entered Region with Name: " + event.geofence.region.name);
console.log("Position: " + event.position.latitude + ", " + event.position.longitude);
};
self.ongeofenceleave = function(event) {
console.log("Exited Region with Name: " + event.geofence.region.name);
console.log("Position: " + event.position.latitude + ", " + event.position.longitude);
};
To see this plugin in action, run the following commands to create the sample app
cordova create GeofenceDemo io.cordova.geofencedemo GeofenceDemo
cd GeofenceDemo
cordova platform add ios
cordova plugin add cordova-plugin-service-worker-geofencing
mv 'plugins/cordova-plugin-service-worker-geofencing/sample/config.xml' 'config.xml'
mv 'plugins/cordova-plugin-service-worker-geofencing/sample/sw.js' 'www/sw.js'
mv 'plugins/cordova-plugin-service-worker-geofencing/sample/index.html' 'www/index.html'
mv 'plugins/cordova-plugin-service-worker-geofencing/sample/js/index.js' 'www/js/index.js'
cordova prepare
Enter a name into the input box and click "Create Geofence at Current Location" to do just that. The messages box will inform you whenever you enter or exit one of the geofences you created.
FAQs
Geofencing plugin for Cordova Service Worker
The npm package cordova-plugin-service-worker-geofencing receives a total of 0 weekly downloads. As such, cordova-plugin-service-worker-geofencing popularity was classified as not popular.
We found that cordova-plugin-service-worker-geofencing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.