License sales launch: April 27, 2026 Get notified or view pricing

bglocation

Migration Guide

Migrating from @capacitor-community/background-geolocation or similar plugins to @bglocation/capacitor.

Migration Steps

  1. Uninstall the old plugin
    npm uninstall @capacitor-community/background-geolocation
  2. Install @bglocation/capacitor
    npm install @bglocation/capacitor
    npx cap sync
  3. Update imports
    // Before
    import { BackgroundGeolocation } from '@capacitor-community/background-geolocation';
    
    // After
    import { BackgroundLocation } from '@bglocation/capacitor';
  4. Update configuration

    Restructure your config options — see the mapping table below.

  5. Replace watchers with event listeners
    // Before
    const watcherId = await BackgroundGeolocation.addWatcher(options, callback);
    
    // After
    BackgroundLocation.addListener('onLocation', (location) => { ... });
    BackgroundLocation.addListener('onHeartbeat', (event) => { ... });
  6. Sync native projects
    npx cap sync
  7. Test on a physical device

    Background location must always be validated on real hardware.

API Mapping

Old APINew APINotes
BackgroundGeolocation.configure()BackgroundLocation.configure()Options restructured — see config changes below
BackgroundGeolocation.start()BackgroundLocation.start()Same behavior
BackgroundGeolocation.stop()BackgroundLocation.stop()Same behavior
BackgroundGeolocation.getCurrentLocation()BackgroundLocation.getCurrentPosition()Renamed method
BackgroundGeolocation.checkStatus()BackgroundLocation.getState()Returns LocationState instead of status object
addWatcher()addListener('onLocation', …)Event-based instead of watcher pattern
N/AaddGeofence() / addGeofences()New geofencing support
N/AgetVersion()New version info
N/AcheckBatteryOptimization()New Android battery check

Configuration Changes

Old OptionNew OptionNotes
interval / minIntervallocationUpdateIntervalUnified interval name (Android)
distanceFilterdistanceFilterSame, but now supports "auto" mode
stationaryRadiusN/ARemoved — use adaptive filter instead
debugdebug / debugSoundsSplit into separate flags
stopAfterTerminateN/APlugin always runs via native service
startOnBootN/ANot supported — re-start manually
N/Ahttp: { url, headers, buffer }New native HTTP posting
N/AautoDistanceFilter: { … }New adaptive filter config
N/AheartbeatIntervalNew heartbeat timer

What You Gain

Native HTTP Posting

Automatic POST with offline buffer and retry — no JS bridge needed.

Geofencing

Up to 20 circular regions with enter, exit, and dwell transitions.

Adaptive Distance Filter

Speed-based auto mode adjusts filter dynamically for optimal battery/accuracy.

Heartbeat Timer

Periodic callbacks even when stationary — know the device is alive.

React Native Support

Same native core powers both Capacitor and React Native wrappers.

Debug Mode

Verbose logs, system sounds, and JS debug events for faster diagnosis.