New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-service-worker-geofencing

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-service-worker-geofencing

Geofencing plugin for Cordova Service Worker

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

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.

Supported Platforms

  • iOS

Installation

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.

Example Usage

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);
};

Sample App

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.

1.0.1 (April 30, 2015)

  • Updated installation instructions

1.0.0 (April 29, 2015)

  • Initial release

Keywords

FAQs

Package last updated on 30 Apr 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc