Skip to content

Installation

Requirements

  • React Native ≥ 0.76 (New Architecture only)
  • iOS ≥ 15.5, Android minSdk 24
  • Expo SDK 54+ if you use the config plugin — a development build, not Expo Go

See Compatibility for the full support matrix.

Install the package

Terminal window
npm install @dc-bgeo/react-native-background-geolocation

Autolinking wires up the native module on both platforms — there is no manual linking step. What’s left on each platform is native project configuration: pods on iOS, a Maven repo + manifest permissions on Android.

iOS setup

Install pods

Terminal window
cd ios && pod install

The podspec vendors the closed-source BGeoCore.xcframework and compiles the open TurboModule bridge against it. It also pulls in React-Core and configures the New Architecture build flags required for the TurboModule and event-emitter glue — you don’t need to do anything beyond pod install. The vendored engine links CoreLocation, CoreMotion, UIKit, and AudioToolbox (the last plays the optional debug cues); CocoaPods resolves all of these automatically.

Info.plist keys

Add these keys to your app’s Info.plist. Each is required for the reason listed:

KeyWhy it’s required
NSLocationAlwaysAndWhenInUseUsageDescriptionShown when requesting Always authorization, needed for background tracking.
NSLocationWhenInUseUsageDescriptionShown for the foreground/“When In Use” step of the authorization prompt.
NSMotionUsageDescriptionShown when the engine reads Core Motion activity (moving/still) to drive the motion state machine.
UIBackgroundModeslocationTells iOS your app performs background location updates; without it, background delivery is silently capped.
ios/YourApp/Info.plist
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We track your location in the background to …</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We use your location to …</string>
<key>NSMotionUsageDescription</key>
<string>We use motion to detect when you start and stop moving.</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>

Write real justification strings — App Store review rejects vague usage descriptions. See Permissions & background location for the full authorization/review guidance.

Enable the Background Modes capability in Xcode

The Info.plist entry above must be paired with the capability enabled in the Xcode project:

  1. Open ios/YourApp.xcworkspace in Xcode.
  2. Select your app target → Signing & Capabilities.
  3. Click + Capability, choose Background Modes.
  4. Check Location updates.
Xcode's Signing & Capabilities tab for the example app target, with the Background Modes capability added and 'Location updates' checked, plus a Location (Always) usage description below it.

Android setup

Add the local Maven repo

The closed engine ships as an AAR in a local Maven repo inside the package. Add that repo to your project’s android/build.gradle:

android/build.gradle
allprojects {
repositories {
maven {
url("$rootDir/../node_modules/@dc-bgeo/react-native-background-geolocation/android/libs")
}
}
}

Autolinking wires up the rest of the Gradle module.

Declare the background-location permission

Google Play policy requires the app, not a library, to own the background-location declaration (and the corresponding Play Console disclosure), so this one is deliberately not merged from the engine AAR:

android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

Permissions merged from the engine AAR

The engine AAR’s manifest merges the rest of the permissions the module needs directly into your app on both setups — you never declare these yourself:

PermissionWhy
ACCESS_FINE_LOCATIONForeground GPS fixes.
ACCESS_COARSE_LOCATIONNetwork/cell-grade location fallback.
ACTIVITY_RECOGNITIONDrives the moving/still motion state machine via Play Services.
FOREGROUND_SERVICERequired to run the tracking foreground service.
FOREGROUND_SERVICE_LOCATIONAndroid 14+ typed foreground-service permission for the location service type.
RECEIVE_BOOT_COMPLETEDResumes tracking after reboot when startOnBoot is enabled.
WAKE_LOCKKeeps the device awake briefly for background processing.
POST_NOTIFICATIONSAndroid 13+ permission for the required tracking notification.
INTERNET / ACCESS_NETWORK_STATENative HTTP upload of queued locations.

The tracking service and its receivers merge in the same way — there is nothing else to declare. See Permissions & background location for the runtime request flow and the Play Console disclosure requirement.

Gradle notes

  • minSdk 24, compileSdk/targetSdk 36 (overridable via rootProject.ext, same safeExtGet pattern RN modules use).
  • Kotlin 2.1.20, Android Gradle Plugin 8.13.0.
  • The module requires the New Architecture (newArchEnabled=true); it applies the com.facebook.react Gradle plugin only when that flag is set.
  • Android namespace is com.bgeo.rn (the bridge); the vendored engine AAR owns the com.bgeo namespace separately, so there’s no resource/R-class clash.

License key

Debuggable builds and the iOS simulator run without a license key — and a placeholder value can’t block them either, since every rejection degrades to unlicensed evaluation in development. Release builds require a real key — see License keys for where it goes and how it’s validated.

Verify the install

Build and run the app on a device or simulator, then confirm the native module loaded:

import BackgroundGeolocation from '@dc-bgeo/react-native-background-geolocation';
const state = await BackgroundGeolocation.getState();
console.log(state); // { enabled: false, ... } — false is expected before ready()/start()

If this resolves without throwing, the native module linked correctly on that platform. See getState() for the full return shape, and Quickstart for wiring up ready()/start() and your first location events.