Capacitor Support for Background Geolocation

Both background-geolocation and background-fetch now have pure Capacitor implementations!

See the Github repos:

The Javascript API is almost identical to the Cordova version, with just one caveat: you must use the Promise api only. For example:

// 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);

However, adding event-listeners never returned a Promise — those do accept a callback argument, just as in the Cordova version — there is no difference with adding event-listeners between the Cordova and Capacitor version.

BackgroundGeolocation.onMotionChange((location) => {
console.log('[onMotionChange]', location);
});

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