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

@digidem/react-native-gps-state

v1.0.0

Published

React Native Listener for GPS status changes

Downloads

6

Readme

React Native GPS State

Fork of neuberoliveira/react-native-gps-state with fixes for latest RN.

React Native Listener for GPS status changes

This lib will emitevent wheneaver the GPS status change, like when the permission was rejected or user disable Location service in system Settings.

Instalation

  1. Add library to project
    • yarn add @digidem/react-native-gps-state
    • OR npm install --save @digidem/react-native-gps-state
  2. Link library to project
    • react-native link @digidem/react-native-gps-state

Usage

Constants

| Platform | Status Code | Constant | Description | :--- | :---: | :--- | :--- | IOS/Android | 0 | NOT_DETERMINED | The user has not yet made a choice regarding whether this app can use location services. | IOS/Android | 1 | RESTRICTED | This app is not authorized to use location services. | IOS/Android | 2 | DENIED | The user explicitly denied the use of location services for this app or location services are currently disabled in Settings. | IOS/Android | 3 | AUTHORIZED | This app is authorized to use location services. | IOS | 3 | AUTHORIZED_ALWAYS | This app is authorized to start location services at any time. | IOS | 4 | AUTHORIZED_WHENINUSE | This app is authorized to start most location services while running in the foreground

Methods

//Open the system Settings to enable user to toggle Location on
GPSState.openSettings();
//Get the current GPS state
GPSState.getStatus().then((status)=>{

});

Listeners

import GPSState from 'react-native-gps-state';
...
componentWillMount(){
	GPSState.addListener((status)=>{
		switch(status){
			case GPSState.NOT_DETERMINED:
				alert('Please, allow the location, for us to do amazing things for you!');
			break;

			case GPSState.RESTRICTED:
				GPSState.openSettings();
			break;

			case GPSState.DENIED:
				alert('It`s a shame that you do not allowed us to use location :(');
			break;

			case GPSState.AUTHORIZED_ALWAYS:
				//TODO do something amazing with you app
			break;

			case GPSState.AUTHORIZED_WHENINUSE:
				//TODO do something amazing with you app
			break;
		}
	});
}

componentWillUnmount(){
	GPSState.removeListener();
}