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-find-background-location-vd

v1.0.7

Published

Android foreground service based background location tracking for React Native

Readme

Hyy Devlopers

react-native-find-background-location-vd

Reliable background location tracking for React Native on Android using a foreground service, designed with Play Store–safe practices and clear behavior guarantees.

✨ Features

  1. Foreground service–based background location tracking

  2. Works when app is:

  3. Minimized

  4. In background

  5. Screen locked

  6. Continuous location updates

  7. Play Store compliant (no hidden restarts, no abusive alarms)

  8. Simple JS API

  9. Does not force background execution after user kills the app (by design)

⚠️ Android Kill-Mode Behavior

Android does NOT guarantee background execution after the user force-closes the app (swipe away from recent apps).

This library uses a foreground service, which:

  • ✅ Works in background
  • ✅ Works with screen off
  • ✅ Works when app is minimized
  • ❌ May stop when app is swiped away (system decision)

This is expected Android behavior and applies to all apps, including Google Maps and Uber, depending on device and OEM settings.

📦 Installation npm install react-native-find-background-location-vd

or yarn add react-native-find-background-location-vd

Autolinking is supported. No manual linking required.

⚠️ Android Permissions (REQUIRED)

Add the following permissions to your app AndroidManifest.xml:

⚠️ Android 14+ requires FOREGROUND_SERVICE_LOCATION Missing it will cause the app to crash immediately.

🚀 Usage Basic example import { useEffect } from 'react'; import { startLocation, stopLocation, onLocation, } from 'react-native-find-background-location-vd';

useEffect(() => { const subscription = onLocation(location => { console.log( '📍 LOCATION:', location.latitude, location.longitude ); });

startLocation();

return () => { stopLocation(); subscription.remove(); }; }, []);

🔐 Request Permissions (IMPORTANT)

You must request runtime permissions before starting location tracking.

import { PermissionsAndroid, Platform } from 'react-native';

export async function requestLocationPermissions() { if (Platform.OS !== 'android') return true;

const fine = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION );

if (fine !== PermissionsAndroid.RESULTS.GRANTED) return false;

if (Platform.Version >= 29) { const bg = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION ); if (bg !== PermissionsAndroid.RESULTS.GRANTED) return false; }

return true; }

📡 API Reference startLocation(): void

Starts background location tracking using a foreground service.

stopLocation(): void

Stops location tracking and removes the foreground notification.

onLocation(callback): Subscription

Registers a listener for location updates.

onLocation((location) => { console.log(location.latitude, location.longitude); });

Returns a subscription with .remove().

👉 Call startLocation() only after permissions are granted.

🔔 Foreground Notification

Android requires a persistent notification while tracking location.

This library automatically shows:

Background Location Location tracking is active

⚠️ Users cannot hide this notification (Android system rule).

🔋 Battery Optimization (Recommended)

For reliable background tracking, ask users to disable battery optimization:

Settings → Battery → Battery Optimization → Your App → Don’t optimize

🏪 Play Store Policy Notice

If you publish an app using this library:

You must declare background location usage

You must justify foreground service

You must show user disclosure

You must allow opt-out

Failure to comply may result in Play Store rejection.

❌ iOS Support

This library does NOT support iOS background location.

iOS code is a stub only

No CoreLocation integration

This repository includes a fully working example app:

cd example yarn android

🙌 Contributing

PRs and issues are welcome. Please follow Android background execution guidelines.

Development workflow

Sending a pull request

Code of conduct

Android only Install app

Grant permissions

Tap Start Location

Show notification

Lock screen → still logs location

Minimize app → still logs

Swipe app away → explain limitation on screen 🧪 Example App

Demo App Flow Background Location On Background Notification For Location

⭐ If this library helps you, please star the repo!

📄 License

MIT

👨‍💻 Maintained by

Vijay Dhakad

Built with ❤️ using create-react-native-library