Capacitor Support for Background Geolocation

// Old API with optional callbacks as method-arguments is
// no longer supported, eg: methodName(successFn)
// use Promise api, eg: methodName().then(successFn)
// OLD callback args not supported.
BackgroundGeolocation.ready(config, (state) => {
console.log('[ready] state:', state);
});
// NEW: Only Promise API is supported:
BackgroundGeolocation.ready(config).then((state) => {
console.log('[ready] state', state);
});
// Or use await in an async function
const state = await BackgroundGeolocation.ready(config);
console.log('[ready] state', state);
// OLD: callback args not supported.
BackgroundGeolocation.getState((state) => {
console.log('[getState]', state);
});
// NEW: Only Promise API is supported:
BackgroundGeolocation.getState().then((state) => {
console.log('[getState]', state);
});
// Or use await in an async function
const state = await BackgroundGeolocation.getState();
console.log('[getState]', state);
// Adding event-listeners is the same as always:
BackgroundGeolocation.onLocation((location) => {
console.log('[onLocation]', location);
}, (error) => {
console.log('[onLocation] ERROR', error);
});
BackgroundGeolocation.onMotionChange((location) => {
console.log('[onMotionChange]', location);
});

--

--

--

Creator of Background Geolocation SDK. Professional plugin developers — geolocation specialists. https://www.transistorsoft.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Auto bump apps versions and releases using GitLab pipeline

Why adding Key is important in ReactJS? Let’s Find Out !

Jumping into JavaScript

Creating a dynamic inline editable table in React — Part 2

How To Secure The Node-RED Editor On A Raspberry Pi 4

How to Create Nested Routes with React Router and Hooks — An In Depth Project Summary

Unit Tests or Integration Tests? The Answer May Lie in the Middle

Build a Cloudinary Image Uploader with ReactJS and NodeJS

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
Transistor Software

Transistor Software

Creator of Background Geolocation SDK. Professional plugin developers — geolocation specialists. https://www.transistorsoft.com

More from Medium

The Most Secure Way To Reopen Schools For Students and Teachers | Free Covid School Environment

What is Russian Vapour?

Undated picture of the Evelyn Street Baths

Classification of email text is spam or ham using Logistic Regression algorithm

Logistic logistic regression