npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-radar

v0.1.0

Published

Cordova plugin for Radar, the location platform for mobile apps

Downloads

2

Readme

Radar is the location platform for mobile apps. This is a Cordova plugin to use its SDK.

This is still under heavy work

Installation

Install the Cordova plugin:

$ cordova plugin install cordova-plugin-radar

Usage

Check the main documentation for details. There's a basic test app example as well.

Initialize

Register and get your keys.

cordova.plugins.radar.initialize(key);

Identify user

Before tracking the user's location, you must identify the user to cordova.plugins.radar. To identify the user, call:

cordova.plugins.radar.setUserId(userId);

where userId is a stable unique ID string for the user.

To set an optional description for the user, displayed in the dashboard, call:

cordova.plugins.radar.setDescription(description);

where description is a string.

You only need to call these methods once, as these settings will be persisted across app sessions.

Enable places

To set Facebook as your place data provider, call:

cordova.plugins.radar.setPlacesProvider('facebook');

Request permissions

Before tracking the user's location, the user must have granted location permissions for the app. These are requested automatically when you initialized radar.

To determine the whether user has granted location permissions for the app, call:

cordova.plugins.radar.getPermissionsStatus().then((status) => {
  // do something with status
});

status will be a string, one of:

  • GRANTED
  • DENIED
  • UNKNOWN

To request location permissions for the app, call:

cordova.plugins.radar.requestPermissions(background);

where background is a boolean indicating whether to request background location permissions or foreground location permissions. On Android, background will be ignored.

Foreground tracking

Once you have initialized the SDK, you have identified the user, and the user has granted permissions, you can track the user's location.

To track the user's location in the foreground, call:

cordova.plugins.radar.trackOnce().then((result) => {
  // do something with result.location, result.events, result.user.geofences
}).catch((err) => {
  // optionally, do something with err
});

err will be a string, one of:

  • ERROR_PUBLISHABLE_KEY: the SDK was not initialized
  • ERROR_USER_ID: the user was not identified
  • ERROR_PERMISSIONS: the user has not granted location permissions for the app
  • ERROR_LOCATION: location services were unavailable, or the location request timed out
  • ERROR_NETWORK: the network was unavailable, or the network connection timed out
  • ERROR_UNAUTHORIZED: the publishable API key is invalid
  • ERROR_SERVER: an internal server error occurred
  • ERROR_UNKNOWN: an unknown error occurred

Background tracking

Once you have initialized the SDK, you have identified the user, and the user has granted permissions, you can start tracking the user's location in the background.

To start tracking the user's location in the background, call:

cordova.plugins.radar.startTracking();

To stop tracking the user's location in the background (e.g., when the user logs out), call:

cordova.plugins.radar.stopTracking();

You only need to call these methods once, as these settings will be persisted across app sessions.

To listen for events and errors, you can add event listeners:

cordova.plugins.radar.onEvents(
	(events, user) => {
		// do something with result.events, result.user
	}
);

cordova.plugins.radar.onError(
 (err) => {
  // do something with err
});

You should remove event listeners when you are done with them:

cordova.plugins.radar.offEvents();

cordova.plugins.radar.offError();

Manual tracking

You can manually update the user's location by calling:

const location = {
  latitude: 39.2904,
  longitude: -76.6122,
  accuracy: 65
};

cordova.plugins.radar.updateLocation(
	{
		latitude: document.getElementById('latitude').value,
		longitude: document.getElementById('longitude').value,
		accuracy: document.getElementById('accuracy').value
	},
	(result) => {
		// do something with result.events, result.user.geofences
		console.log(result);
	}
);