πŸš€ Migration Guide: Flat Config β†’ Compound Config

March 26, 2026 Β· View on GitHub

Version: 5.0.0
Applies to: react-native-background-geolocation v5.0.0 and above

πŸ“’ Overview

Version 5.x introduces two important changes:

  1. A new JWT-based License Key format that encodes add-on product entitlements (eg: polygon-geofencing, firebase) β€” separate add-on keys are no longer required.
  2. A new Compound Config format that replaces the legacy "flat" config structure.

This guide explains both changes and how to migrate your app.

πŸ”‘ New License Key Format

Overview

New License Key Format

Version 9 uses a new JWT-based license key format. Your existing (legacy) license keys will not work with v9.

Important

Previous versions of the SDK did not require a license key on iOS. v5 requires a license key on both iOS and Android. See iOS Setup and Android Setup or Expo Setup for license key configuration details.

Note

Add-on products (eg: polygon-geofencing, firebase) are now encoded as entitlements inside the JWT key itself. You no longer need separate license keys for add-on products.

Getting Your New License Key

  1. Log in to the Transistor Software Customer Dashboard.
  2. Navigate to your product purchase.
  3. You will find two license tabs:
    • Legacy β€” your old license key (for react-native-background-geolocation v4 and below)
    • New β€” your new JWT license key (required for capacitor-background-geolocation v5+)
  4. Copy the key from the "New" tab.

Applying Your License Key

  • [iOS] Add your JWT license key to your Info.plist under the key TSLocationManagerLicense. See iOS Setup for full details:

:open_file_folder: ios/App/App/Info.plist

<key>TSLocationManagerLicense</key>
<string>YOUR_JWT_LICENSE_KEY</string>
  • [Android] Add your JWT license key to AndroidManifest.xml. See Android Setup for full details:

:open_file_folder: android/app/src/main/AndroidManifest.xml

<manifest>
    <application>
        <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_JWT_LICENSE_KEY" />
    </application>
</manifest>

Warning

If you previously configured a separate license key for polygon-geofencing, firebase, or any other add-on product, remove it. Add-on entitlements are now bundled into your single bgGeo JWT license key.

Compound Config

Version 5 introduces a new Compound Config format that replaces the legacy β€œflat” config structure. This guide explains how to migrate, shows before/after examples, and highlights key differences for the React Native SDK.

βš™οΈ Compatibility

The legacy flat config style remains fully supported for backward compatibility.
You can continue using your existing flat configuration if you prefer, though new features may only appear in the compound structure.

Recommendation: New apps and major refactors should migrate to the compound config to stay aligned with the native SDKs and shared type system.

⏩ Why Compound Config?

  • Clarity: Groups related settings together (geolocation, HTTP, logging, app lifecycle, etc).
  • Extensibility: Easier to add new config domains without polluting the top-level.
  • Consistency: Aligns with native SDKs and shared TypeScript types across platforms.
  • Tooling: Better IntelliSense / autocomplete when using @transistorsoft/background-geolocation-types.

πŸ—οΈ Old vs. New Config Structure (React Native)

Before (Flat Config – JS/TS)

import BackgroundGeolocation from 'react-native-background-geolocation';

BackgroundGeolocation.ready({
  desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
  distanceFilter: 50,
  stopOnTerminate: false,
  startOnBoot: true,
  url: 'https://my.server.com/locations',
  headers: { Authorization: 'Bearer TOKEN' },
  logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE
  debug: true,
});

After (Compound Config)

import BackgroundGeolocation from 'react-native-background-geolocation';

BackgroundGeolocation.ready({
  geolocation: {
    desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.High,
    distanceFilter: 50,
  },
  app: {
    stopOnTerminate: false,
    startOnBoot: true,
  },
  http: {
    url: 'https://my.server.com/locations',
    headers: { Authorization: 'Bearer TOKEN' },
  },
  logger: {
    logLevel: BackgroundGeolocation.LogLevel.Verbose,
    debug: true,
  },
});

πŸ—ΊοΈ Mapping Table: Flat β†’ Compound

Flat KeyCompound GroupCompound PropertyExample
desiredAccuracygeolocationdesiredAccuracygeolocation: GeoConfig(desiredAccuracy: ...)
distanceFiltergeolocationdistanceFilter
stopOnTerminateappstopOnTerminateapp: AppConfig(stopOnTerminate: ...)
startOnBootappstartOnBoot
urlhttpurlhttp: HttpConfig(url: ...)
headershttpheaders
logLevelloggerlogLevellogger: LoggerConfig(logLevel: ...)
debugloggerdebug
.........

See the full mapping table below for all properties.

πŸ§‘β€πŸ’» Migration Steps

  1. Update your dependency:
    Ensure you are using react-native-background-geolocation v5.0.0 or later.

  2. [Android] remove custom maven url from android/build.gradle. These are no longer required:

:open_file_folder: android/build.gradle

    repositories {
        google()
        mavenCentral()
-       maven { url 'https://developer.huawei.com/repo/' }
-       // [required] background_geolocation
-       maven(url = "${project(":flutter_background_geolocation").projectDir}/libs")
-       // [required] background_fetch
-       maven(url = "${project(":background_fetch").projectDir}/libs")
    }
}
  1. Group related options:

    • Move geolocation-related keys into GeoConfig
    • Move HTTP-related keys into HttpConfig
    • Move logging/debug keys into LoggerConfig
    • Move app lifecycle keys into AppConfig
    • Move activity-recognition keys into ActivityConfig
    • Move persistence keys into PersistenceConfig
  2. Replace flat keys:

    • Instead of passing all options to Config(...) directly, pass the relevant compound config objects.
    • Remove any duplicate or conflicting flat keys.
  3. Check for breaking changes:

    • Some keys may have been renamed, moved, or refactored.
    • See Breaking Changes below.

πŸ“ Example Migration

Flat Config (Old)

BackgroundGeolocation.ready({
  desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
  distanceFilter: 10,
  stopOnTerminate: false,
  startOnBoot: true,
  url: "https://my.server.com/locations",
  headers: { "Authorization": "Bearer TOKEN" },
  logLevel: BackgroundGeolocation.LOG_LEVEL_DEBUG,
  debug: true,
  autoSync: true,
  batchSync: false,
});

Compound Config (New)

BackgroundGeolocation.ready({
  geolocation: {
    desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.High,
    distanceFilter: 10,
  },
  app: {
    stopOnTerminate: false,
    startOnBoot: true,
  },
  http: {
    url: "https://my.server.com/locations",
    headers: { "Authorization": "Bearer TOKEN" },
    autoSync: true,
    batchSync: false,
  },
  logger: {
    logLevel: BackgroundGeolocation.LogLevel.High
    debug: true,
  }
));

🧩 Compound Config Groups

GroupClass NameDescription
geolocationGeoConfigLocation and geofencing options
appAppConfigApp lifecycle and scheduling
httpHttpConfigHTTP sync, batching, headers, etc.
loggerLoggerConfigDebug, log-level, log retention
activityActivityConfigActivity recognition, stop detection
persistencePersistenceConfigData storage, max days, max records

Each group is a separate Dart class. See API docs for details.

πŸ› οΈ Full Mapping Table

Flat KeyCompound GroupCompound PropertyNotes
desiredAccuracygeolocationdesiredAccuracy
distanceFiltergeolocationdistanceFilter
stationaryRadiusgeolocationstationaryRadius
stopTimeoutgeolocationstopTimeout
stopAfterElapsedMinutesgeolocationstopAfterElapsedMinutes
geofenceProximityRadiusgeolocationgeofenceProximityRadius
geofenceInitialTriggerEntrygeolocationgeofenceInitialTriggerEntry
geofenceModeHighAccuracygeolocationgeofenceModeHighAccuracy
pausesLocationUpdatesAutomaticallygeolocationpausesLocationUpdatesAutomatically
showsBackgroundLocationIndicatorgeolocationshowsBackgroundLocationIndicator
activityTypegeolocationactivityTypeiOS only
locationAuthorizationAlertgeolocationlocationAuthorizationAlertiOS only
maxMonitoredGeofencesgeolocationmaxMonitoredGeofences
filtergeolocationfilterAdvanced filtering
stopOnTerminateappstopOnTerminate
startOnBootappstartOnBoot
enableHeadlessappenableHeadlessAndroid only
heartbeatIntervalappheartbeatInterval
scheduleappschedule
scheduleUseAlarmManagerappscheduleUseAlarmManagerAndroid only
notificationappnotificationAndroid only
backgroundPermissionRationaleappbackgroundPermissionRationaleAndroid only
preventSuspendapppreventSuspendiOS only
urlhttpurl
autoSynchttpautoSync
autoSyncThresholdhttpautoSyncThreshold
disableAutoSyncOnCellularhttpdisableAutoSyncOnCellular
batchSynchttpbatchSync
maxBatchSizehttpmaxBatchSize
methodhttpmethod
paramshttpparams
headershttpheaders
rootProperty/httpRootPropertyhttprootProperty
timeout/httpTimeouthttptimeout
debugloggerdebug
logLevelloggerlogLevelNow an enum: LogLevel
logMaxDaysloggerlogMaxDays
activityRecognitionIntervalactivityactivityRecognitionIntervalAndroid only
minimumActivityRecognitionConfidenceactivityminimumActivityRecognitionConfidenceAndroid only
disableStopDetectionactivitydisableStopDetection
stopOnStationaryactivitystopOnStationary
motionTriggerDelayactivitymotionTriggerDelayAndroid only
triggerActivitiesactivitytriggerActivitiesAndroid only
disableMotionActivityUpdatesactivitydisableMotionActivityUpdatesiOS only
stopDetectionDelayactivitystopDetectionDelayiOS only
persistModepersistencepersistMode
maxDaysToPersistpersistencemaxDaysToPersist
maxRecordsToPersistpersistencemaxRecordsToPersist
locationsOrderDirectionpersistencelocationsOrderDirection

Not all legacy keys are shown above. See API docs for full details.

⚠️ Breaking Changes

  • Some keys have new enum types:
    • logLevel is now a LogLevel enum (e.g., LogLevel.info), but legacy integer values are still supported for backward compatibility. You may use either the new enum or the legacy integer type.
  • Some keys have moved to new groups:
    • E.g., debug is now in LoggerConfig.
  • Legacy flat config remains supported but deprecated:
    • Using the legacy flat config will show warnings at runtime, but will not result in an error. Migration to the new grouped config is recommended for future compatibility.

πŸ§ͺ Testing Your Migration

  1. Run your app after migration.
  2. Check for errors or warnings about missing or misplaced config keys.
  3. Review logs to ensure config is applied as expected.
  4. Consult the API docs for each config group if unsure.

πŸ†˜ Need Help?

πŸ“š Resources

πŸŽ‰ Happy Migrating!

If you have suggestions for improving this guide, please open a PR or issue.