

Radar is the location platform for mobile apps.
Installation
In an HTML page, include the SDK using a <script>
tag:
<script src="https://js.radar.io/v1-beta/radar.js"></script>
In a web app, install the package from npm, then import the module:
npm install --save radar-sdk-js
import Radar from 'radar-sdk-js';
The SDK is less than 10 KB minified.
Usage
Initialize SDK
To initialize the SDK, call:
Radar.initialize(publishableKey);
where publishableKey
is a string containing your Radar publishable API key.
To get a Radar publishable API key, sign up for a Radar account.
Enable Places
If you are using Places, you must set Facebook as your place data provider.
To set Facebook as your place data provider, call:
Radar.setPlacesProvider(Radar.PLACES_PROVIDER.FACEBOOK);
To disable Places later, call:
Radar.setPlacesProvider(Radar.PLACES_PROVIDER.NONE);
Learn more about Places.
Identify user
Until you identify the user, Radar will automatically identify the user by a random UUID "device ID" stored in a cookie.
To identify the user when logged in, call:
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:
Radar.setDescription(description);
where description
is a string.
You only need to call these functions once, as these settings will be persisted across browser sessions in cookies.
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.
The SDK uses the HTML5 geolocation API to determine the user's location.
To track the user's location, call:
Radar.trackOnce(function(status, location, user, events) {
});
status
will be a string, one of:
Radar.STATUS.SUCCESS
: the request succeededRadar.STATUS.ERROR_PUBLISHABLE_KEY
: the SDK was not initializedRadar.STATUS.ERROR_PERMISSIONS
: the user has not granted location permissions for the websiteRadar.STATUS.ERROR_LOCATION
: location services were unavailable, or the location request timed outRadar.STATUS.ERROR_NETWORK
: the network was unavailable, or the network connection timed outRadar.STATUS.ERROR_UNAUTHORIZED
: the publishable API key is invalidRadar.STATUS.ERROR_RATE_LIMIT
: exceeded rate limit of 1 request per second per user or 60 requests per hour per userRadar.STATUS.ERROR_SERVER
: an internal server error occurred
Support
Have questions? We're here to help! Email us at support@radar.io.