New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tuup/react-native-gps-state

Package Overview
Dependencies
Maintainers
8
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tuup/react-native-gps-state

React Native Listener for GPS status changes

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
8
Weekly downloads
 
Created
Source

React Native GPS State

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 react-native-gps-state
    • OR npm install --save react-native-gps-state
  2. Link library to project
    • react-native link react-native-gps-state

Usage

Constants

PlatformStatus CodeConstantDescription
IOS/Android0NOT_DETERMINEDThe user has not yet made a choice regarding whether this app can use location services.
IOS/Android1RESTRICTEDThis app is not authorized to use location services.
IOS/Android2DENIEDThe user explicitly denied the use of location services for this app or location services are currently disabled in Settings.
IOS/Android3AUTHORIZEDThis app is authorized to use location services.
IOS3AUTHORIZED_ALWAYSThis app is authorized to start location services at any time.
IOS4AUTHORIZED_WHENINUSEThis 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();
}

Keywords

FAQs

Package last updated on 12 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc