[New Feature] Background Geolocation Typescript API

The Background Geolocation SDK for both Cordova and React Native now provides its own comprehensive Typescript API.


Up until now, in order to use the SDK with Ionic, you had to fetch a reference from the window object:

let bgGeo = (<any>window).BackgroundGeolocation;

No more: assuming the plugin has been added to node_modules (which $ ionic cordova plugin add... already does), you can now simply import it:

import BackgroundGeolocation from "cordova-background-geolocation"

React Native

From here on, the API for both React Native and Cordova are identical. They both share the same typescript definitions, so going forward from here, the only difference is where you import "it" from.


Import interfaces as needed. On event-callbacks, for example:


All the SDK’s documentation has been migrated from the old markdown files into the definition.d.ts files themselves, making it possible to auto-generate them using Typedoc and published to transistorsoft.github.io:

Document-management is much simpler now and docs themselves more enjoyable to write with the easy linking throughout the API. Typedoc’s templating system is great and I’m importing my own custom template. The docs are sure to evolve from here on.


Now you have code-assist. For example, start typing "BackgroundGeolocation.get

Since the docs have been migrated into the SDK’s Typescriptdefinitions.d.ts, a snippet of the docs will appear on hovering members, such as distanceFilter:

Method / event signatures:

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store