react-native-location-enabler
This package makes it easy for an React Native App to ensure that the Android device's system settings are properly configured for the app's location needs. If your app needs to request location, the device needs to enable the appropriate system settings, such as GPS or Wi-Fi scanning. Rather than directly enabling services such as the device's GPS, your app specifies the required level of accuracy/power consumption, and the device automatically makes the appropriate changes to system settings.
Installation
Usage
Example using Hook (React Hooks API) :
Example using Listener :
Example React Native App :
Clone the repo
Install npm dependencies
Start Metro ( javascript bundler )
Install and launch example app on the device
API
Properties
PRIORITIES
Static object contain a list quality of service for location updates. If your application wants high accuracy location it should set prioprity to 'HIGH_ACCURACY'. If you want negligible power impact, but to still receive location updates when available, then set priority to 'NO_POWER'.
Methods
useLocationSettings({ priority, alwaysShow, needBle }, initialStatus?)
Hook let you check the user's device location status 'on' / 'off' and method let you display an activity where they can turn location 'on'.
checkSettings({ priority, alwaysShow, needBle })
Checking if the user's device location is turned on / off.
requestResolutionSettings({ priority, alwaysShow, needBle })
Display an activity where they can turn location 'on' using a location request.
addListener(callback, context?)
Adds a listener to be invoked when onChangeLocationSettings are emitted. An optional calling context may be provided. The data arguments emitted will be passed to the listener function.