react-native-location-services-settings
v1.0.0
Published
## Getting started
Downloads
1
Readme
react-native-react-native-location-services-settings
Getting started
$ npm install react-native-react-native-location-services-settings --save
Mostly automatic installation
$ react-native link react-native-react-native-location-services-settings
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNReactNativeLocationServicesSettingsPackage;
to the imports at the top of the file - Add
new RNReactNativeLocationServicesSettingsPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-react-native-location-services-settings' project(':react-native-react-native-location-services-settings').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-react-native-location-services-settings/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-react-native-location-services-settings')
Usage
// possible values: 'high_accuracy', 'balanced_power_accuracy', 'low_power'
ReactNativeLocationServicesSettings.checkStatus('high_accuracy').then(res => {
if (!res.enabled) {
ReactNativeLocationServicesSettings.askForEnabling(res => {
if (res) {
console.log('location services were allowed by the user')
} else {
console.log('location services were denied by the user')
}
})
}
})