react-native-android-location-service
React Native Android Location using Location Manager You should using with 'react-native-android-location-services-dialog-box' & 'react-native-android-settings-library' for check all case of turn on/off location in Android device
Getting started
$ npm install react-native-android-location-service --save
Mostly automatic installation
$ react-native link react-native-android-location-service
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import co.twinger.location.RNAndroidLocationServicePackage;
to the imports at the top of the file - Add
new RNAndroidLocationServicePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-android-location-service' project(':react-native-android-location-service').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-location-service/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-android-location-service')
Add Permissions and used Google API to your Project
Add this to your AndroidManifest file;
// file: android/app/src/main/AndroidManifest.xml
Usage
;;; ; state = lng: 00 lat: 00 { this; if !thiseventEmitter // Register Listener Callback - has to be removed later thiseventEmitter = DeviceEventEmitter; // Initialize RNGLocation RNAndroidLocationService; } { this; } { // Stop listening for Events thiseventEmitter; } //request permission to access location { Permissions ; } { return <View> <Text>Test location</Text> <Text>Lng: thisstatelng Lat: thisstatelat</Text> </View> ; }