Giter Club home page Giter Club logo

ably-asset-tracking-js's Introduction

Ably Asset Tracking SDK for JavaScript

.github/workflows/check.yml

Overview

Ably Asset Tracking SDKs provide an easy way to track multiple assets with realtime location updates powered by Ably realtime network and Mapbox Navigation SDK with location enhancement.

Status: this is a preview version of the SDK. That means that it contains a subset of the final SDK functionality, and the APIs are subject to change. The latest release of this SDK is available in the Released section of this repository.

Ably Asset Tracking is:

  • easy to integrate - comprising two complementary SDKs with easy to use APIs, available for multiple platforms:
    • Asset Publishing SDK, for embedding in apps running on the courier's device
    • Asset Subscribing SDK, for embedding in apps runnong on the customer's observing device
  • extensible - as Ably is used as the underlying transport, you have direct access to your data and can use Ably integrations for a wide range of applications in addition to direct realtime subscriptions - examples include:
    • passing to a 3rd party system
    • persistence for later retrieval
  • built for purpose - the APIs and underlying functionality are designed specifically to meet the requirements of a range of common asset tracking use-cases

This repository contains the Asset Subscribing SDK for Web.

Usage

Here is an example of how the SDK can be used:

import { Subscriber, Accuracy } from 'ably-asset-tracking';

const ablyOptions = {
  key: ABLY_API_KEY,
  clientId: CLIENT_ID,
};

// Define a callback to be notified when a location update is recieved.
const onLocationUpdate = (locationUpdate) => {
  console.log(`Location update recieved. Coordinates: ${locationUpdate.location.geometry.coordinates}`);
};

// Define a callback to be notified when the asset online status is updated.
const onStatusUpdate = (isOnline) => {
  console.log(`Status update: Publisher is now ${isOnline ? 'online' : 'offline'}`);
};

// Request a specific resolution to be considered by the publisher.
const resolution = {
  accuracy: Accuracy.High,
  desiredInterval: 1000,
  minimumDisplacement: 1,
};

// Initialise the subscriber.
const subscriber = new Subscriber({
  ablyOptions,
  onLocationUpdate,
  onStatusUpdate,
});

const trackingId = '<some application defined asset tracking identifier>';

(async () => {
  // Start tracking an asset using its tracking identifier.
  await subscriber.start(trackingId);

  // Request a new resolution to be considered by the publisher.
  await subscriber.sendChangeRequest({
    accuracy: Accuracy.Low,
    desiredInterval: 3000,
    minimumDisplacement: 5,
  });

  // Stop tracking the asset.
  await subscriber.stop();
})();

Example App

This repository also contains an example app that showcases how the Ably Asset Tracking SDK can be used:

Development

see Contributing.

ably-asset-tracking-js's People

Contributors

kavalerov avatar niksilver avatar owenpearson avatar quintinwillison avatar thisisjofrank avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.