Skip to content

Latest commit

 

History

232 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-background-location

Background GPS tracking and geofencing for React Native, built on the New Architecture.

NPM Version NPM Beta NPM Downloads NPM Total Downloads CI Tests Code Coverage Pre-release CI Release CI GitHub Stars License Bundlephobia Platform Android Platform iOS TypeScript

A TurboModule for the React Native New Architecture. Drives a foreground service on Android and CLLocationManager on iOS, persists every fix to Room and Core Data, and ships native geofencing plus crash recovery so trips survive process death.

Read the full documentation

Features

  • Background tracking with configurable accuracy and distance filter
  • Native geofencing (GeofencingClient on Android, CLCircularRegion on iOS)
  • Persistent location storage (Room on Android, Core Data on iOS)
  • Crash recovery via WorkManager and significant location monitoring
  • React hooks: useBackgroundLocation, useLocationPermissions, useLocationUpdates, useLocationTracking
  • Expo config plugin for managed workflows

Requirements

Requirement Version
React Native >=0.73 (New Architecture required)
iOS >=16.0
Android minSdk 24

Installation

Bare React Native (recommended)

yarn add @gabriel-sisjr/react-native-background-location
cd ios && pod install

Autolinking handles Android manifest merging and iOS pod registration. Bare iOS apps must still add NSLocationWhenInUseUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationAlwaysUsageDescription, and a UIBackgroundModes entry containing location to their Info.plist. See the iOS setup guide for full details.

Quick Start

import {
  startTracking,
  useLocationUpdates,
} from '@gabriel-sisjr/react-native-background-location';

function App() {
  const { locations } = useLocationUpdates();

  return (
    <Button
      title="Start"
      onPress={() => startTracking({ tripId: 'trip-1', distanceFilter: 10 })}
    />
  );
}

See the documentation site for the full hook reference and the permission flow that must run before tracking starts.

Documentation

License

MIT — see LICENSE.

About

A React Native library for tracking location in the background using TurboModules (New Architecture). Track user location even when the app is minimized or in the background.

Topics

Resources

Code of conduct

Contributing

Stars

26 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages