npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-bg-geo

v0.1.1

Published

Background geolocation SDK (New Architecture) — original implementation

Readme

react-native-bg-geo

An original, New-Architecture background-geolocation library scaffold for iOS + Android. Every subsystem has a home in the codebase. Core paths (location capture, SQLite queue, HTTP upload with lock/unlock, motion switching) are implemented; tuning-heavy parts are marked TODO — that's where the ongoing work lives (see "Status").

Your own implementation built on the public platform APIs (FusedLocationProvider / CoreLocation, WorkManager, Room/SQLite). Not derived from any commercial SDK's source.

Install into a demo app

# demo app must have New Architecture enabled
npm install ../react-native-bg-geo
cd ios && RCT_NEW_ARCH_ENABLED=1 pod install && cd ..
npx react-native run-android   # or run-ios

New Arch on: newArchEnabled=true in android/gradle.properties + the pod install above.

iOS Info.plist (demo app) — COMPLETE set

<key>NSLocationWhenInUseUsageDescription</key><string>...</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key><string>...</string>
<key>NSLocationAlwaysUsageDescription</key><string>...</string>
<key>NSMotionUsageDescription</key><string>...</string>   <!-- required: CMMotionActivityManager -->
<key>UIBackgroundModes</key>
<array><string>location</string><string>fetch</string><string>processing</string></array>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array><string>com.bggeo.sync</string><string>com.bggeo.heartbeat</string></array>

Permissions are handled SDK-side

The app never requests anything itself — call requestPermission() and the SDK drives the whole flow: Android FINE → ACTIVITY_RECOGNITION → POST_NOTIFICATIONS → BACKGROUND_LOCATION (Settings deep-link on API 30+); iOS WhenInUse → Always + Motion. Resolves 0=denied, 3=when-in-use, 4=always. Android: the library manifest declares permissions + the FGS location type. The demo app must still request runtime permission (FINE, then BACKGROUND) at run time.

Usage

import BackgroundGeolocation from 'react-native-bg-geo';

BackgroundGeolocation.onLocation(loc => console.log('[location]', loc));
BackgroundGeolocation.onHttp(r => console.log('[http]', r.status, r.success));

await BackgroundGeolocation.requestPermission();
await BackgroundGeolocation.ready({
  geolocation: { desiredAccuracy: -1, distanceFilter: 10 },
  http: { url: 'https://your.server.com/locations', autoSync: true, batchSync: false,
          headers: { Authorization: 'Bearer <token>' }, params: { device_id: 'demo-1' } },
  persistence: { maxDaysToPersist: 7, extras: { app: 'demo' } },
  app: { stopOnTerminate: false, startOnBoot: true, foregroundService: true },
});
await BackgroundGeolocation.start();

HTTP wire format (single mode)

{ "device_id": "demo-1",
  "location": { "uuid": "...", "timestamp": "...", "coords": { }, "is_moving": true } }

A record is deleted from the queue ONLY on a 2xx; any other status unlocks it for retry.

Status

Implemented (testable end-to-end on device): location capture + odometer + distance filter (both platforms); SQLite queue with lock/unlock + delete-on-2xx; HTTP single & batch upload with params/headers/auto-sync (Android WorkManager, iOS URLSession); foreground service (Android) / background modes (iOS); basic motion-based accuracy switching; main event bridge.

Stubbed (TODO in code): getCurrentPosition/watchPosition; multi-step FINE->BACKGROUND permission flow; geofence proximity re-loading beyond OS limit, DWELL, polygons; headless / terminated-app JS execution; scheduler + heartbeat; template rendering; battery/OEM survival tuning; Kalman/accuracy filter pipeline; stationary stop-detection.

Build notes

NativeBgGeoSpec (Android) and NativeBgGeoSpecJSI/BgGeoSpec (iOS) are produced by RN codegen from src/NativeBgGeo.ts on first build — IDE "missing symbol" warnings before a build are expected. Android needs apply plugin: 'com.facebook.react' (already in gradle).