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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-bg-location

v0.1.6

Published

The react-native-bg-location package is a versatile and easy-to-use library for handling background location tracking in React Native applications. It provides a seamless way to access the device's location in the background, making it suitable for variou

Downloads

6

Readme

You can utilize this npm package on iOS right now, and we're in the process of bringing it to Android.

react-native-bg-location

You can utilize this npm package on iOS right now, and we're in the process of bringing it to Android.

The react-native-bg-location package is a versatile and easy-to-use library for handling background location tracking in React Native applications. It provides a seamless way to access the device's location in the background, making it suitable for various use cases, including tracking user movements, geofencing.

Installation for ios

npm install react-native-bg-location

```bash

cd ios && pod install

Configure Background Capabilities

Open your App in XCode and select the root of your project. Select Capabilities tab. Enable Background Modes and enable the following modes:

  • [x] Location updates
  • [x] Background fetch

Configure Usage Strings in Info.plist

Edit Info.plist. Add the following items (Set Value as desired):

| Key | Type | Value | |-----|-------|-------------| | Privacy - Location Always and When in Use Usage Description | String | CHANGEME: Location required in background | | Privacy - Location When in Use Usage Description | String | CHANGEME: Location required when app is in use | | Privacy - Motion Usage Description | String | CHANGEME: Motion permission helps detect when device in in-motion |

Demo video

https://github.com/gulsher7/react-native-bg-location/assets/56266123/1ddc7db2-d07c-49d2-8bb4-b07d1b669847


## Usage

```js
import { LocationEvent, setDesiredDistance, startLocation, stopLocation } from 'react-native-bg-location';

// ...
    
 1. setDesiredDistance(distance: number)

This function sets the desired distance for location updates. 
It takes a numeric parameter distance (in meters) and returns a Promise. 
It fetches the location after the device moves the specified distance.

   
setDesiredDistance(50).then((res) => {  //example send value in meters
    console.log(res)
  }).catch((error) => {
    console.log("Error code:", error);
  })

2. startLocation()
   use this function to start location tracking. It continuously updates the device's location.
  

3. stopLocation()
   To stop location tracking, call this function.

4. LocationEvent.addListener(eventType: string, callback: (data: any) => void)

    LocationEvent.addListener("LAT_LNG", (latlng) => { //example
    console.log("data", latlng);
    });

5. LocationEvent.removeAllListeners(eventType: string)
   To remove all listeners for a specific event type, you can use this function. 
   
   LocationEvent.removeAllListeners("LAT_LNG"); //example

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library