4.2.0 • Published 2 days ago

radar-sdk-js v4.2.0

Weekly downloads
238
License
ISC
Repository
-
Last release
2 days ago

Radar

npm CircleCI branch Codecov

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) {
  // do something with status, location, user, events
});

status will be a string, one of:

  • Radar.STATUS.SUCCESS: the request succeeded
  • Radar.STATUS.ERROR_PUBLISHABLE_KEY: the SDK was not initialized
  • Radar.STATUS.ERROR_PERMISSIONS: the user has not granted location permissions for the website
  • Radar.STATUS.ERROR_LOCATION: location services were unavailable, or the location request timed out
  • Radar.STATUS.ERROR_NETWORK: the network was unavailable, or the network connection timed out
  • Radar.STATUS.ERROR_UNAUTHORIZED: the publishable API key is invalid
  • Radar.STATUS.ERROR_RATE_LIMIT: exceeded rate limit of 1 request per second per user or 60 requests per hour per user
  • Radar.STATUS.ERROR_SERVER: an internal server error occurred

Support

Have questions? We're here to help! Email us at support@radar.io.

4.2.1-beta.1

2 days ago

4.2.0

3 days ago

4.2.0-beta.5

3 days ago

4.2.0-beta.4

21 days ago

4.2.0-beta.3

24 days ago

4.2.0-beta.1

29 days ago

4.1.19-beta.0

1 month ago

4.1.18

3 months ago

4.1.18-beta.0

3 months ago

4.1.17-beta.1

4 months ago

4.1.17-beta.0

4 months ago

4.1.17-beta.4

4 months ago

4.1.17-beta.3

4 months ago

4.1.17-beta.2

4 months ago

4.1.17

4 months ago

4.1.16

4 months ago

4.1.14

4 months ago

4.1.15

4 months ago

4.1.13

4 months ago

4.1.13-beta.1

5 months ago

4.1.12-beta.4

5 months ago

4.1.12-beta.5

5 months ago

4.1.12-beta.0

5 months ago

4.1.12-beta.2

5 months ago

4.2.1-beta.0

7 months ago

4.1.12

5 months ago

4.1.5-beta.0

9 months ago

4.1.8

8 months ago

4.1.7

8 months ago

4.1.9

8 months ago

4.0.1

10 months ago

4.0.0

10 months ago

4.1.6-beta.0

8 months ago

4.1.8-beta.1

8 months ago

4.2.0-beta.0

7 months ago

4.1.10-beta.2

8 months ago

4.1.10-beta.1

8 months ago

4.1.10-beta.0

8 months ago

4.0.0-beta.22

10 months ago

4.0.0-beta.21

10 months ago

4.0.0-beta.24

10 months ago

4.0.0-beta.23

10 months ago

4.0.0-beta.20

10 months ago

4.0.0-beta.15

11 months ago

4.0.0-beta.14

11 months ago

4.0.0-beta.17

11 months ago

4.0.0-beta.16

11 months ago

4.0.0-beta.11

11 months ago

4.0.0-beta.10

11 months ago

4.0.0-beta.13

11 months ago

4.0.0-beta.12

11 months ago

4.0.0-beta.19

11 months ago

4.0.0-beta.18

11 months ago

4.1.2-beta.0

9 months ago

4.1.11

8 months ago

3.7.2-beta.1

11 months ago

4.0.0-beta.8

11 months ago

4.0.0-beta.7

11 months ago

4.0.0-beta.6

11 months ago

4.0.0-beta.5

11 months ago

4.0.0-beta.4

11 months ago

4.0.2-beta.0

10 months ago

4.0.1-beta.0

10 months ago

4.0.1-beta.1

10 months ago

4.0.2-beta.2

9 months ago

4.0.2-beta.1

10 months ago

4.1.4

9 months ago

4.1.3

9 months ago

4.1.6

8 months ago

4.1.5

9 months ago

4.1.0

9 months ago

4.1.2

9 months ago

4.1.1

9 months ago

4.0.0-beta.9

11 months ago

3.5.1-beta

1 year ago

3.7.1-beta.8

1 year ago

3.7.1-beta.7

1 year ago

3.7.1-beta.2

1 year ago

3.7.1-beta.1

1 year ago

3.6.0-beta

1 year ago

3.6.1

1 year ago

3.6.0

1 year ago

3.6.2-beta.2

1 year ago

3.6.2-beta.1

1 year ago

3.7.1

1 year ago

3.7.0

1 year ago

3.5.1

1 year ago

3.7.1-beta.12

1 year ago

3.7.1-beta.11

1 year ago

3.5.0

1 year ago

3.5.0-beta.2

2 years ago

3.3.0-beta.3

2 years ago

3.3.0

2 years ago

3.5.0-beta

2 years ago

3.4.0-beta

2 years ago

3.5.0-beta.1

2 years ago

3.3.0-beta.2

2 years ago

3.3.0-beta.1

2 years ago

3.2.1

2 years ago

3.2.1-beta.1

2 years ago

3.2.0

2 years ago

3.2.0-beta.1

2 years ago

3.1.0-beta.10

2 years ago

3.1.0-beta.11

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.0-beta.9

3 years ago

3.1.0-beta.8

3 years ago

3.1.0-beta.7

3 years ago

3.1.0-beta.6

3 years ago

3.1.0-beta.5

3 years ago

3.1.0-beta.3

3 years ago

3.1.0-beta.4

3 years ago

3.1.0-beta.2

3 years ago

3.1.0-beta.1

3 years ago

3.1.0-beta

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

3.0.0-beta.8

4 years ago

3.0.0-beta.7

4 years ago

3.0.0-beta.6

4 years ago

3.0.0-beta.4

4 years ago

3.0.0-beta.3

4 years ago

3.0.0-beta.2

4 years ago

3.0.0-beta.1

4 years ago

3.0.0-beta

4 years ago

1.1.0

5 years ago

1.0.0

5 years ago

1.0.0-beta5

5 years ago

1.0.0-beta4

5 years ago

1.0.0-beta3

6 years ago

1.0.0-beta2

6 years ago

1.0.0-beta

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago